From commits-return-7986-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Thu Oct 26 05:33:36 2006 Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 39477 invoked from network); 26 Oct 2006 00:22:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Oct 2006 00:22:06 -0000 Received: (qmail 15949 invoked by uid 500); 25 Oct 2006 10:55:19 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 15927 invoked by uid 500); 25 Oct 2006 10:55:19 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 15916 invoked by uid 99); 25 Oct 2006 10:55:19 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Oct 2006 03:55:19 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Oct 2006 03:55:04 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 7ED681A9846; Wed, 25 Oct 2006 03:54:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r467600 - in /apr/apr/trunk: CHANGES include/apr_network_io.h network_io/unix/sendrecv.c test/testsockets.c Date: Wed, 25 Oct 2006 10:54:44 -0000 To: commits@apr.apache.org From: jorton@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061025105444.7ED681A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jorton Date: Wed Oct 25 03:54:41 2006 New Revision: 467600 URL: http://svn.apache.org/viewvc?view=rev&rev=467600 Log: Fixes for the implementation, documentation and test case for apr_socket_recvfrom(); * network_io/unix/sendrecv.c (apr_socket_recvfrom): Reset the socklen argument correctly before calling recvfrom. On success, update all the sockaddr variables for the address returned, not just the port. * include/apr_network_io.h (apr_socket_recvfrom): Document a little better. * test/testsockets.c (sendto_receivefrom): Check that the address is set correctly. Modified: apr/apr/trunk/CHANGES apr/apr/trunk/include/apr_network_io.h apr/apr/trunk/network_io/unix/sendrecv.c apr/apr/trunk/test/testsockets.c Modified: apr/apr/trunk/CHANGES URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?view=diff&rev=467600&r1=467599&r2=467600 ============================================================================== --- apr/apr/trunk/CHANGES (original) +++ apr/apr/trunk/CHANGES Wed Oct 25 03:54:41 2006 @@ -1,4 +1,8 @@ Changes for APR 1.3.0 + + *) Fix apr_socket_recvfrom() to ensure the peer's address is returned + through the "from" parameter. [Joe Orton] + *) Fix error checking in kqueue, epoll and event port versions of apr_pollset_create. PR 40660, 40661, 40662 [Larry Cipriani ] Modified: apr/apr/trunk/include/apr_network_io.h URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_network_io.h?view=diff&rev=467600&r1=467599&r2=467600 ============================================================================== --- apr/apr/trunk/include/apr_network_io.h (original) +++ apr/apr/trunk/include/apr_network_io.h Wed Oct 25 03:54:41 2006 @@ -507,7 +507,11 @@ apr_size_t *len); /** - * @param from The apr_sockaddr_t to fill in the recipient info + * Read data from a socket. On success, the address of the peer from + * which the data was sent is copied into the @param from parameter, + * and the @param len parameter is updated to give the number of bytes + * written to @param buf. + * @param from Updated with the address from which the data was received * @param sock The socket to use * @param flags The flags to use * @param buf The buffer to use Modified: apr/apr/trunk/network_io/unix/sendrecv.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/sendrecv.c?view=diff&rev=467600&r1=467599&r2=467600 ============================================================================== --- apr/apr/trunk/network_io/unix/sendrecv.c (original) +++ apr/apr/trunk/network_io/unix/sendrecv.c Wed Oct 25 03:54:41 2006 @@ -148,6 +148,8 @@ apr_size_t *len) { apr_ssize_t rv; + + from->salen = sizeof(from->sa); do { rv = recvfrom(sock->socketdes, buf, (*len), flags, @@ -172,7 +174,7 @@ return errno; } - from->port = ntohs(from->sa.sin.sin_port); + apr_sockaddr_vars_set(from, from->sa.sin.sin_family, ntohs(from->sa.sin.sin_port)); (*len) = rv; if (rv == 0 && sock->type == SOCK_STREAM) { Modified: apr/apr/trunk/test/testsockets.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testsockets.c?view=diff&rev=467600&r1=467599&r2=467600 ============================================================================== --- apr/apr/trunk/test/testsockets.c (original) +++ apr/apr/trunk/test/testsockets.c Wed Oct 25 03:54:41 2006 @@ -159,8 +159,9 @@ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, STRLEN, len); - /* Zero out the port so we can be sure it's been set by recvfrom. */ - from->port = 0; + /* fill the "from" sockaddr with a random address to ensure that + * recvfrom sets it up properly. */ + apr_sockaddr_info_get(&from, "127.1.2.3", APR_INET, 4242, 0, p); len = 80; rv = apr_socket_recvfrom(from, sock, 0, recvbuf, &len);