mturk 2002/10/04 03:12:53 Modified: jk/native2/common jk_channel_apr_socket.c Log: Fix the apr_socket default timeout value. Also fix the send/recv that caused wrong header readings. Revision Changes Path 1.28 +32 -22 jakarta-tomcat-connectors/jk/native2/common/jk_channel_apr_socket.c Index: jk_channel_apr_socket.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_apr_socket.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- jk_channel_apr_socket.c 3 Oct 2002 01:33:14 -0000 1.27 +++ jk_channel_apr_socket.c 4 Oct 2002 10:12:52 -0000 1.28 @@ -216,7 +216,7 @@ int ndelay=socketInfo->ndelay; int keepalive=socketInfo->keepalive; - apr_socket_t *sock=endpoint->channelData; + apr_socket_t *sock; apr_status_t ret; apr_int32_t timeout = (apr_int32_t)(socketInfo->timeout * APR_USEC_PER_SEC); char msg[128]; @@ -232,7 +232,8 @@ remote_sa = remote_sa->next; continue; } - + /* store the channel information */ + endpoint->channelData=sock; env->l->jkLog(env, env->l, JK_LOG_INFO, "channelApr.open(): create tcp socket %d\n", sock ); @@ -240,8 +241,9 @@ /* the default timeout (0) will set the socket to blocking with infinite timeouts. */ + if (timeout <= 0) - apr_socket_timeout_set(sock, 0); + apr_socket_timeout_set(sock, -1); else apr_socket_timeout_set(sock, timeout); @@ -296,9 +298,6 @@ env->l->jkLog(env, env->l, JK_LOG_DEBUG, "channelApr.open(), sock = %d\n", sock); - /* store the channel information */ - endpoint->channelData=sock; - return JK_OK; } @@ -360,13 +359,20 @@ b=msg->buf; length = (apr_size_t) len; - stat = apr_send(sock, b, &length); - if (stat!= APR_SUCCESS) { - env->l->jkLog(env, env->l, JK_LOG_ERROR, - "jk2_channel_apr_send send failed %d %s\n", - stat, apr_strerror( stat, data, sizeof(data) ) ); - return -3; /* -2 is not possible... */ - } + do { + apr_size_t written = length; + + stat = apr_send(sock, b, &written); + if (stat!= APR_SUCCESS) { + env->l->jkLog(env, env->l, JK_LOG_ERROR, + "jk2_channel_apr_send send failed %d %s\n", + stat, apr_strerror( stat, data, sizeof(data) ) ); + return -3; /* -2 is not possible... */ + } + length -= written; + b += written; + } while (length); + return JK_OK; } @@ -395,17 +401,21 @@ return JK_ERR; rdlen = 0; + length = (apr_size_t)len; + while (rdlen < len) { - length = (apr_size_t) len; - stat = apr_recv(sock, b, &length); + stat = apr_recv(sock, b + rdlen, &length); - if ( stat == APR_EOF) - return -1; /* socket closed. */ - else if ( stat == APR_SUCCESS) { - rdlen = (int) length; - return rdlen; - } else - return -1; /* any error. */ + if (stat == APR_EOF) + return -1; /* socket closed. */ + else if (APR_STATUS_IS_EAGAIN(stat)) + continue; + else if (stat != APR_SUCCESS) + return -1; /* any error. */ + rdlen += length; + length = (apr_size_t)(len - rdlen); + } + return rdlen; } /** receive len bytes.
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>