tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jean-frederic clere <jfrederic.cl...@fujitsu-siemens.com>
Subject Re: jk_connect and multi-threading
Date Tue, 13 Jul 2004 07:08:12 GMT
Henri Gomez wrote:
> Henri Gomez wrote:
> 
>> Bill Barker wrote:
>>
>>> ----- Original Message -----
>>> From: "Henri Gomez" <hgomez@apache.org>
>>> To: "Tomcat Developers List" <tomcat-dev@jakarta.apache.org>
>>> Sent: Monday, July 12, 2004 3:07 AM
>>> Subject: jk_connect and multi-threading
>>>
>>>
>>>
>>>> Hi to all,
>>>>
>>>> I'm looking for a strange problem under iSeries (AS/400) and wonder
>>>> about this look in jk_open_socket() (jk_connect.c) :
>>>>
>>>>         do {
>>>>             jk_log(l, JK_LOG_DEBUG, "jk_open_socket, try to connect
>>>> socket = %d to %s\n",
>>>>                    sock, jk_dump_hinfo(addr, buf));
>>>>
>>>>             ret = connect(sock,
>>>>                           (struct sockaddr *)addr,
>>>>                           sizeof(struct sockaddr_in));
>>>> #if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
>>>>             if(SOCKET_ERROR == ret) {
>>>>                 errno = WSAGetLastError() - WSABASEERR;
>>>>             }
>>>> #endif /* WIN32 */
>>>>             jk_log(l, JK_LOG_DEBUG, "jk_open_socket, after connect ret
>>>> = %d\n", ret);
>>>>         } while (-1 == ret && EINTR == errno);
>>>>
>>>>
>>>> What's the status on errno in multi-threaded environnement ?
>>>>
>>>
>>>
>>> On older *nix boxes it wasn't safe to use it with threads.  Don't 
>>> know about
>>> iSeries.  On Solaris it's per-thread (assuming that you've compiled
>>> with -D_REENTRANT).
>>>
>>>
>>>> Shouldn't we clear errno before the connect() call ?
>>>>
>>>
>>>
>>> It's not supposed to matter.
>>>
>>>
>>>> BTW, I wonder why we check the errno in such case...
>>
>>
>>
>> Ok, I take a look at IBM errno list and error 3021 is for EINVAL 
>> (invalid argument).
>>
>> I'll investigate this error farther...
> 
> 
> The problem could be related to BSD 4.4/Unix 98 where the sa_len should 
> be defined before connect call. May be one of the various reason where
> jk_connect failed strangely on many boxes.

Yes, APR uses:
+++
apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
{
     int rc;

     do {
         rc = connect(sock->socketdes,
                      (const struct sockaddr *)&sa->sa.sin,
                      sa->salen);
     } while (rc == -1 && errno == EINTR);
+++
So setting  sa_len and USING sa_len instead sizeof(sockaddr_in) in the socket() 
should fix most of the problems.

> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message