You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bo...@apache.org on 2009/11/01 07:10:19 UTC
svn commit: r831643 - in /apr/apr/branches/1.3.x: ./ file_io/unix/
network_io/unix/ test/
Author: bojan
Date: Sun Nov 1 06:10:18 2009
New Revision: 831643
URL: http://svn.apache.org/viewvc?rev=831643&view=rev
Log:
Backport r831641 from the trunk.
Set file/socket descriptor to -1 before close(), so that there is no chance
of returning an already closed FD from apr_os_file_get()/apr_os_sock_get().
Modified:
apr/apr/branches/1.3.x/ (props changed)
apr/apr/branches/1.3.x/file_io/unix/open.c
apr/apr/branches/1.3.x/network_io/unix/sockets.c
apr/apr/branches/1.3.x/test/NWGNUaprtest (props changed)
apr/apr/branches/1.3.x/test/NWGNUglobalmutexchild (props changed)
apr/apr/branches/1.3.x/test/NWGNUmod_test (props changed)
apr/apr/branches/1.3.x/test/NWGNUproc_child (props changed)
apr/apr/branches/1.3.x/test/NWGNUreadchild (props changed)
apr/apr/branches/1.3.x/test/NWGNUsockchild (props changed)
apr/apr/branches/1.3.x/test/NWGNUtestatmc (props changed)
apr/apr/branches/1.3.x/test/NWGNUtryread (props changed)
Propchange: apr/apr/branches/1.3.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,2 +1,2 @@
/apr/apr/branches/1.4.x:783970
-/apr/apr/trunk:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588,794485,795267,799497,800627,809854,829490
+/apr/apr/trunk:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588,794485,795267,799497,800627,809854,829490,831641
Modified: apr/apr/branches/1.3.x/file_io/unix/open.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/file_io/unix/open.c?rev=831643&r1=831642&r2=831643&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/file_io/unix/open.c (original)
+++ apr/apr/branches/1.3.x/file_io/unix/open.c Sun Nov 1 06:10:18 2009
@@ -29,10 +29,14 @@
static apr_status_t file_cleanup(apr_file_t *file, int is_child)
{
apr_status_t rv = APR_SUCCESS;
+ int fd = file->filedes;
- if (close(file->filedes) == 0) {
- file->filedes = -1;
+ /* Set file descriptor to -1 before close(), so that there is no
+ * chance of returning an already closed FD from apr_os_file_get().
+ */
+ file->filedes = -1;
+ if (close(fd) == 0) {
/* Only the parent process should delete the file! */
if (!is_child && (file->flags & APR_DELONCLOSE)) {
unlink(file->fname);
@@ -44,6 +48,9 @@
#endif
}
else {
+ /* Restore, close() was not successful. */
+ file->filedes = fd;
+
/* Are there any error conditions other than EINTR or EBADF? */
rv = errno;
}
Modified: apr/apr/branches/1.3.x/network_io/unix/sockets.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/network_io/unix/sockets.c?rev=831643&r1=831642&r2=831643&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/network_io/unix/sockets.c (original)
+++ apr/apr/branches/1.3.x/network_io/unix/sockets.c Sun Nov 1 06:10:18 2009
@@ -31,12 +31,20 @@
static apr_status_t socket_cleanup(void *sock)
{
apr_socket_t *thesocket = sock;
+ int sd = thesocket->socketdes;
- if (close(thesocket->socketdes) == 0) {
- thesocket->socketdes = -1;
+ /* Set socket descriptor to -1 before close(), so that there is no
+ * chance of returning an already closed FD from apr_os_sock_get().
+ */
+ thesocket->socketdes = -1;
+
+ if (close(sd) == 0) {
return APR_SUCCESS;
}
else {
+ /* Restore, close() was not successful. */
+ thesocket->socketdes = sd;
+
return errno;
}
}
Propchange: apr/apr/branches/1.3.x/test/NWGNUaprtest
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,3 +1,3 @@
/apr/apr/branches/1.4.x/test/nwgnuaprtest:783970
-/apr/apr/trunk/test/NWGNUaprtest:794485,795267,799497,800627,809854,829490
+/apr/apr/trunk/test/NWGNUaprtest:794485,795267,799497,800627,809854,829490,831641
/apr/apr/trunk/test/nwgnuaprtest:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588
Propchange: apr/apr/branches/1.3.x/test/NWGNUglobalmutexchild
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,3 +1,3 @@
/apr/apr/branches/1.4.x/test/nwgnuglobalmutexchild:783970
-/apr/apr/trunk/test/NWGNUglobalmutexchild:794485,795267,799497,800627,809854,829490
+/apr/apr/trunk/test/NWGNUglobalmutexchild:794485,795267,799497,800627,809854,829490,831641
/apr/apr/trunk/test/nwgnuglobalmutexchild:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588
Propchange: apr/apr/branches/1.3.x/test/NWGNUmod_test
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,3 +1,3 @@
/apr/apr/branches/1.4.x/test/nwgnumod_test:783970
-/apr/apr/trunk/test/NWGNUmod_test:794485,795267,799497,800627,809854,829490
+/apr/apr/trunk/test/NWGNUmod_test:794485,795267,799497,800627,809854,829490,831641
/apr/apr/trunk/test/nwgnumod_test:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588
Propchange: apr/apr/branches/1.3.x/test/NWGNUproc_child
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,3 +1,3 @@
/apr/apr/branches/1.4.x/test/nwgnuproc_child:783970
-/apr/apr/trunk/test/NWGNUproc_child:794485,795267,799497,800627,809854,829490
+/apr/apr/trunk/test/NWGNUproc_child:794485,795267,799497,800627,809854,829490,831641
/apr/apr/trunk/test/nwgnuproc_child:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588
Propchange: apr/apr/branches/1.3.x/test/NWGNUreadchild
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,3 +1,3 @@
/apr/apr/branches/1.4.x/test/nwgnureadchild:783970
-/apr/apr/trunk/test/NWGNUreadchild:794485,795267,799497,800627,809854,829490
+/apr/apr/trunk/test/NWGNUreadchild:794485,795267,799497,800627,809854,829490,831641
/apr/apr/trunk/test/nwgnureadchild:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588
Propchange: apr/apr/branches/1.3.x/test/NWGNUsockchild
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,3 +1,3 @@
/apr/apr/branches/1.4.x/test/nwgnusockchild:783970
-/apr/apr/trunk/test/NWGNUsockchild:794485,795267,799497,800627,809854,829490
+/apr/apr/trunk/test/NWGNUsockchild:794485,795267,799497,800627,809854,829490,831641
/apr/apr/trunk/test/nwgnusockchild:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588
Propchange: apr/apr/branches/1.3.x/test/NWGNUtestatmc
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,3 +1,3 @@
/apr/apr/branches/1.4.x/test/nwgnutestatmc:783970
-/apr/apr/trunk/test/NWGNUtestatmc:794485,795267,799497,800627,809854,829490
+/apr/apr/trunk/test/NWGNUtestatmc:794485,795267,799497,800627,809854,829490,831641
/apr/apr/trunk/test/nwgnutestatmc:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588
Propchange: apr/apr/branches/1.3.x/test/NWGNUtryread
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 1 06:10:18 2009
@@ -1,3 +1,3 @@
/apr/apr/branches/1.4.x/test/nwgnutryread:783970
-/apr/apr/trunk/test/NWGNUtryread:794485,795267,799497,800627,809854,829490
+/apr/apr/trunk/test/NWGNUtryread:794485,795267,799497,800627,809854,829490,831641
/apr/apr/trunk/test/nwgnutryread:712674,733052,742752,747990,748361,748371,748565,748988,749810,782838,783398,783958,788588