Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jun 2005 16:43:05 +0300
From:      Vasil Dimov <vd@datamax.bg>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        clement@FreeBSD.org, odumat@netkom-sachsen.de
Subject:   ports/82731: [patch] net/libnss-mysql is unable to connect to the mysql server via tcp
Message-ID:  <20050628134305.GA53143@sinanica.bg.datamax>
Resent-Message-ID: <200506281350.j5SDo32R000830@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         82731
>Category:       ports
>Synopsis:       [patch] net/libnss-mysql is unable to connect to the mysql server via tcp
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 28 13:50:03 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Vasil Dimov
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
DataMax
>Environment:

>Description:

As reported in ports/82476, libnss-mysql's connecting to mysql server
fails immediately after attemp has began.

The problem is that mysql_options(MYSQL_OPT_CONNECT_TIMEOUT) is called
with last argument "3", to set the desired connect timeout to 3 seconds,
but, according to http://dev.mysql.com/doc/mysql/en/mysql-options.html
the argument should be unsigned int *, e.g. unsigned int x = 3, then &x
This causes too large timeout (something like 164514388) to be passed
as a timeout value resulting in subsequent select(2) call returning
EINVAL (22).

from select(2):
[EINVAL]           The specified time limit is invalid.  One of its com-
                   ponents is negative or too large.

Note that this prog may be able to connect in some circumstances when
connect(2) (with non-blocking socket) returns success immediately,
instead of EINPROGESS, or if the select(2) implementation does not
consider something like 164514388 (nearly 51 years! :) as a too large
timeout. *But* the 3 seconds timeout has never been working.

>How-To-Repeat:

>Fix:

--- libnss-mysql_def_timeout.diff begins here ---
diff -urN libnss-mysql.orig/Makefile libnss-mysql/Makefile
--- libnss-mysql.orig/Makefile	Tue Jun 28 16:16:04 2005
+++ libnss-mysql/Makefile	Tue Jun 28 16:11:49 2005
@@ -7,6 +7,7 @@
 
 PORTNAME=	libnss-mysql
 PORTVERSION=	1.4
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	libnss-mysql
diff -urN libnss-mysql.orig/files/patch-src::mysql.c libnss-mysql/files/patch-src::mysql.c
--- libnss-mysql.orig/files/patch-src::mysql.c	Thu Jan  1 02:00:00 1970
+++ libnss-mysql/files/patch-src::mysql.c	Tue Jun 28 16:18:50 2005
@@ -0,0 +1,15 @@
+--- src/mysql.c.orig	Tue Jun 28 16:05:53 2005
++++ src/mysql.c	Tue Jun 28 16:18:17 2005
+@@ -137,10 +137,11 @@
+ _nss_mysql_set_options (sql_server_t *server)
+ {
+   DN ("_nss_mysql_set_options")
++  static const unsigned	def_timeout = DEF_TIMEOUT;
+ 
+   DENTER
+ 
+-  mysql_options(&ci.link, MYSQL_OPT_CONNECT_TIMEOUT, DEF_TIMEOUT);
++  mysql_options(&ci.link, MYSQL_OPT_CONNECT_TIMEOUT, &def_timeout);
+   mysql_options(&ci.link, MYSQL_READ_DEFAULT_GROUP, "libnss-mysql");
+ 
+   DEXIT
diff -urN libnss-mysql.orig/files/patch-src::nss_mysql.h libnss-mysql/files/patch-src::nss_mysql.h
--- libnss-mysql.orig/files/patch-src::nss_mysql.h	Thu Jan  1 02:00:00 1970
+++ libnss-mysql/files/patch-src::nss_mysql.h	Tue Jun 28 16:18:32 2005
@@ -0,0 +1,11 @@
+--- src/nss_mysql.h.orig	Tue Jun 28 16:06:14 2005
++++ src/nss_mysql.h	Tue Jun 28 16:17:30 2005
+@@ -70,7 +70,7 @@
+ #define MAX_QUERY_ATTEMPTS  3           /* # of query retries */
+ 
+ /* Default initializers */
+-#define DEF_TIMEOUT     "3"
++#define DEF_TIMEOUT	3
+ 
+ #ifdef DEBUG
+ void _nss_mysql_debug (char *fmt, ...);
--- libnss-mysql_def_timeout.diff ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050628134305.GA53143>