From kian@dev.housing.wwu.edu  Thu Jul 24 21:20:09 2008
Return-Path: <kian@dev.housing.wwu.edu>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A6D0B1065670
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 24 Jul 2008 21:20:09 +0000 (UTC)
	(envelope-from kian@dev.housing.wwu.edu)
Received: from dev.housing.wwu.edu (dev.housing.wwu.edu [140.160.12.171])
	by mx1.freebsd.org (Postfix) with ESMTP id 7D1268FC1A
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 24 Jul 2008 21:20:09 +0000 (UTC)
	(envelope-from kian@dev.housing.wwu.edu)
Received: from dev.housing.wwu.edu (localhost [127.0.0.1])
	by dev.housing.wwu.edu (8.14.2/8.14.2) with ESMTP id m6OL3X8Q062926
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 24 Jul 2008 14:03:33 -0700 (PDT)
	(envelope-from kian@dev.housing.wwu.edu)
Received: (from kian@localhost)
	by dev.housing.wwu.edu (8.14.2/8.14.2/Submit) id m6OL3XsK062925;
	Thu, 24 Jul 2008 14:03:33 -0700 (PDT)
	(envelope-from kian)
Message-Id: <200807242103.m6OL3XsK062925@dev.housing.wwu.edu>
Date: Thu, 24 Jul 2008 14:03:33 -0700 (PDT)
From: Kian Mohageri <kian.mohageri@gmail.com>
Reply-To: Kian Mohageri <kian.mohageri@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: connect(2) returning -1, errno unset
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         125940
>Category:       kern
>Synopsis:       [libc] connect(2) returning -1, errno unset
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 24 21:30:02 UTC 2008
>Closed-Date:    Fri Jul 25 09:01:59 UTC 2008
>Last-Modified:  Fri Jul 25 09:01:59 UTC 2008
>Originator:     Kian Mohageri
>Release:        FreeBSD 7.0-RELEASE-p3 i386
>Organization:
>Environment:
System: FreeBSD dev.housing.wwu.edu 7.0-RELEASE-p3 FreeBSD 7.0-RELEASE-p3 #0: Mon Jul 14 18:32:03 PDT 2008 root@dev.housing.wwu.edu:/usr/obj/usr/src/sys/GENERIC i386


	
>Description:

Using FreeTDS 0.82 I ran into this issue.  For some reason, the connection is failing (not sure why still).  connect(2) is returning -1 to indicate failure, but errno is unset.

The relevant code from freetds-0.82 follows:

    retval = connect(tds->s, (struct sockaddr *) &sin, sizeof(sin));
    if (retval == 0) {
        tdsdump_log(TDS_DBG_INFO2, "connection established\n");
    } else {
        tdsdump_log(TDS_DBG_ERROR, "tds_open_socket: connect(2) returned \"%s\"\n",        strerror(sock_errno));

Debugging this further shows that retval is -1, but sock_errno (errno) is set to 0.  Setting it to an arbitrary value prior to connect(2) reveals that it isn't touched at all after the failed connect(2).

>How-To-Repeat:

Not entirely sure how to repeat it in a more generic environment.  This specific case is happening with php5-pdo_dblib, freetds-0.64 or freetds-0.82, and PHP via the command line.

>Fix:

	


>Release-Note:
>Audit-Trail:

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: "Kian Mohageri" <kian.mohageri@gmail.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/125940: connect(2) returning -1, errno unset
Date: Thu, 24 Jul 2008 21:32:55 -0700

 On Thu, Jul 24, 2008 at 2:03 PM, Kian Mohageri <kian.mohageri@gmail.com> wrote:
 >
 >>Description:
 >
 > Using FreeTDS 0.82 I ran into this issue.  For some reason, the connection is failing (not sure why still).  connect(2) is returning -1 to indicate failure, but errno is unset.
 >
 > The relevant code from freetds-0.82 follows:
 >
 >    retval = connect(tds->s, (struct sockaddr *) &sin, sizeof(sin));
 >    if (retval == 0) {
 >        tdsdump_log(TDS_DBG_INFO2, "connection established\n");
 >    } else {
 >        tdsdump_log(TDS_DBG_ERROR, "tds_open_socket: connect(2) returned \"%s\"\n",        strerror(sock_errno));
 >
 > Debugging this further shows that retval is -1, but sock_errno (errno) is set to 0.  Setting it to an arbitrary value prior to connect(2) reveals that it isn't touched at all after the failed connect(2).
 >
 >>How-To-Repeat:
 >
 > Not entirely sure how to repeat it in a more generic environment.  This specific case is happening with php5-pdo_dblib, freetds-0.64 or freetds-0.82, and PHP via the command line.
 
 Could you please provide these steps for us?
 Thanks,
 -Garrett

From: "Kian Mohageri" <kian.mohageri@gmail.com>
To: "Garrett Cooper" <yanefbsd@gmail.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/125940: connect(2) returning -1, errno unset
Date: Fri, 25 Jul 2008 01:09:17 -0700

 On Thu, Jul 24, 2008 at 9:32 PM, Garrett Cooper <yanefbsd@gmail.com> wrote:
 > On Thu, Jul 24, 2008 at 2:03 PM, Kian Mohageri <kian.mohageri@gmail.com> wrote:
 >>
 >>>Description:
 >>
 >> Using FreeTDS 0.82 I ran into this issue.  For some reason, the connection is failing (not sure why still).  connect(2) is returning -1 to indicate failure, but errno is unset.
 >>
 >> The relevant code from freetds-0.82 follows:
 >>
 >>    retval = connect(tds->s, (struct sockaddr *) &sin, sizeof(sin));
 >>    if (retval == 0) {
 >>        tdsdump_log(TDS_DBG_INFO2, "connection established\n");
 >>    } else {
 >>        tdsdump_log(TDS_DBG_ERROR, "tds_open_socket: connect(2) returned \"%s\"\n",        strerror(sock_errno));
 >>
 >> Debugging this further shows that retval is -1, but sock_errno (errno) is set to 0.  Setting it to an arbitrary value prior to connect(2) reveals that it isn't touched at all after the failed connect(2).
 >>
 >>>How-To-Repeat:
 >>
 >> Not entirely sure how to repeat it in a more generic environment.  This specific case is happening with php5-pdo_dblib, freetds-0.64 or freetds-0.82, and PHP via the command line.
 >
 > Could you please provide these steps for us?
 
 I apologize.  I still don't know what was going on and why connect(2)
 wasn't setting errno, but it appears the underlying problem has to do
 with an (unknown?) conflict between php5-pdo_oci/php5_oci and
 php5-pdo_dblib.  I'm looking into this further.
 
 Sorry for the noise, please close this.
 
 -Kian
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Fri Jul 25 09:01:46 UTC 2008 
State-Changed-Why:  
Closed at submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=125940 
>Unformatted:
