apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1809757 - in /apr/apr/trunk/file_io: netware/pipe.c os2/pipe.c unix/pipe.c win32/pipe.c
Date Tue, 26 Sep 2017 15:37:42 GMT
Author: ylavic
Date: Tue Sep 26 15:37:42 2017
New Revision: 1809757

URL: http://svn.apache.org/viewvc?rev=1809757&view=rev
Log:
pipe: factorize apr_file_pipe_create*() in terms of static helper
file_pipe_create(), to avoid duplicated code.


Modified:
    apr/apr/trunk/file_io/netware/pipe.c
    apr/apr/trunk/file_io/os2/pipe.c
    apr/apr/trunk/file_io/unix/pipe.c
    apr/apr/trunk/file_io/win32/pipe.c

Modified: apr/apr/trunk/file_io/netware/pipe.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/netware/pipe.c?rev=1809757&r1=1809756&r2=1809757&view=diff
==============================================================================
--- apr/apr/trunk/file_io/netware/pipe.c (original)
+++ apr/apr/trunk/file_io/netware/pipe.c Tue Sep 26 15:37:42 2017
@@ -133,10 +133,13 @@ APR_DECLARE(apr_status_t) apr_os_pipe_pu
     return apr_os_pipe_put_ex(file, thefile, 0, pool);
 }
 
-static apr_status_t file_pipe_create(apr_file_t **in, apr_file_t **out,
-        apr_pool_t *pool_in, apr_pool_t *pool_out)
+static apr_status_t file_pipe_create(apr_file_t **in,
+                                     apr_file_t **out,
+                                     apr_int32_t blocking,
+                                     apr_pool_t *pool_in,
+                                     apr_pool_t *pool_out)
 {
-    int         filedes[2];
+    int filedes[2];
 
     if (pipe(filedes) == -1) {
         return errno;
@@ -172,12 +175,6 @@ static apr_status_t file_pipe_create(apr
     apr_pool_cleanup_register((*out)->pool, (void *)(*out), apr_unix_file_cleanup,
                          apr_pool_cleanup_null);
 
-    return APR_SUCCESS;
-}
-
-static void file_pipe_block(apr_file_t **in, apr_file_t **out,
-        apr_int32_t blocking)
-{
     switch (blocking) {
     case APR_FULL_BLOCK:
         break;
@@ -192,11 +189,15 @@ static void file_pipe_block(apr_file_t *
         apr_file_pipe_timeout_set(*in, 0);
         break;
     }
+    return APR_SUCCESS;
 }
 
-APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t
*pool)
+APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
+                                               apr_file_t **out,
+                                               apr_pool_t *pool)
 {
-    return file_pipe_create(in, out, pool, pool);
+    /* Default is full blocking pipes. */
+    return file_pipe_create(in, out, APR_FULL_BLOCK, pool, pool);
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, 
@@ -204,29 +205,16 @@ APR_DECLARE(apr_status_t) apr_file_pipe_
                                                   apr_int32_t blocking,
                                                   apr_pool_t *pool)
 {
-    apr_status_t status;
-
-    if ((status = file_pipe_create(in, out, pool, pool)) != APR_SUCCESS) {
-        return status;
-    }
-
-    file_pipe_block(in, out, blocking);
-
-    return APR_SUCCESS;
+    return file_pipe_create(in, out, blocking, pool, pool);
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create_pools(apr_file_t **in,
-        apr_file_t **out, apr_int32_t blocking, apr_pool_t *pool_in, apr_pool_t *pool_out)
+                                                     apr_file_t **out,
+                                                     apr_int32_t blocking,
+                                                     apr_pool_t *pool_in,
+                                                     apr_pool_t *pool_out)
 {
-    apr_status_t status;
-
-    if ((status = file_pipe_create(in, out, pool_in, pool_out)) != APR_SUCCESS) {
-        return status;
-    }
-
-    file_pipe_block(in, out, blocking);
-
-    return APR_SUCCESS;
+    return file_pipe_create(in, out, blocking, pool_in, pool_out);
 }
 
 APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, 

Modified: apr/apr/trunk/file_io/os2/pipe.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/os2/pipe.c?rev=1809757&r1=1809756&r2=1809757&view=diff
==============================================================================
--- apr/apr/trunk/file_io/os2/pipe.c (original)
+++ apr/apr/trunk/file_io/os2/pipe.c Tue Sep 26 15:37:42 2017
@@ -123,12 +123,6 @@ static apr_status_t file_pipe_create(apr
     apr_pool_cleanup_register(pool_out, *out, apr_file_cleanup,
             apr_pool_cleanup_null);
 
-    return APR_SUCCESS;
-}
-
-static void file_pipe_block(apr_file_t **in, apr_file_t **out,
-        apr_int32_t blocking)
-{
     switch (blocking) {
     case APR_FULL_BLOCK:
         break;
@@ -143,13 +137,15 @@ static void file_pipe_block(apr_file_t *
         apr_file_pipe_timeout_set(*in, 0);
         break;
     }
+    return APR_SUCCESS;
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
                                                apr_file_t **out,
                                                apr_pool_t *pool)
 {
-    return file_pipe_create(in, out, pool, pool);
+    /* Default is full blocking pipes. */
+    return file_pipe_create(in, out, APR_FULL_BLOCK, pool, pool);
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, 
@@ -157,14 +153,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_
                                                   apr_int32_t blocking,
                                                   apr_pool_t *pool)
 {
-    apr_status_t status;
-
-    if ((status = file_pipe_create(in, out, pool, pool)) != APR_SUCCESS)
-        return status;
-
-    file_pipe_block(in, out, blocking);
-
-    return APR_SUCCESS;
+    return file_pipe_create(in, out, blocking, pool, pool);
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create_pools(apr_file_t **in,
@@ -173,14 +162,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_
                                                      apr_pool_t *pool_in,
                                                      apr_pool_t *pool_out)
 {
-    apr_status_t status;
-
-    if ((status = file_pipe_create(in, out, pool_in, pool_out)) != APR_SUCCESS)
-        return status;
-
-    file_pipe_block(in, out, blocking);
-
-    return APR_SUCCESS;
+    return file_pipe_create(in, out, blocking, pool_in, pool_out);
 }
     
     

Modified: apr/apr/trunk/file_io/unix/pipe.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/pipe.c?rev=1809757&r1=1809756&r2=1809757&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/pipe.c (original)
+++ apr/apr/trunk/file_io/unix/pipe.c Tue Sep 26 15:37:42 2017
@@ -176,8 +176,11 @@ APR_DECLARE(apr_status_t) apr_os_pipe_pu
     return apr_os_pipe_put_ex(file, thefile, 0, pool);
 }
 
-static apr_status_t file_pipe_create(apr_file_t **in, apr_file_t **out,
-        apr_pool_t *pool_in, apr_pool_t *pool_out)
+static apr_status_t file_pipe_create(apr_file_t **in,
+                                     apr_file_t **out,
+                                     apr_int32_t blocking,
+                                     apr_pool_t *pool_in,
+                                     apr_pool_t *pool_out)
 {
     int filedes[2];
 
@@ -220,11 +223,7 @@ static apr_status_t file_pipe_create(apr
                          apr_pool_cleanup_null);
     apr_pool_cleanup_register((*out)->pool, (void *)(*out), apr_unix_file_cleanup,
                          apr_pool_cleanup_null);
-    return APR_SUCCESS;
-}
 
-static void file_pipe_block(apr_file_t **in, apr_file_t **out, apr_int32_t blocking)
-{
     switch (blocking) {
     case APR_FULL_BLOCK:
         break;
@@ -239,12 +238,15 @@ static void file_pipe_block(apr_file_t *
         apr_file_pipe_timeout_set(*in, 0);
         break;
     }
+    return APR_SUCCESS;
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
-        apr_file_t **out, apr_pool_t *pool)
+                                               apr_file_t **out,
+                                               apr_pool_t *pool)
 {
-    return file_pipe_create(in, out, pool, pool);
+    /* Default is full blocking pipes. */
+    return file_pipe_create(in, out, APR_FULL_BLOCK, pool, pool);
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, 
@@ -252,29 +254,16 @@ APR_DECLARE(apr_status_t) apr_file_pipe_
                                                   apr_int32_t blocking,
                                                   apr_pool_t *pool)
 {
-    apr_status_t status;
-
-    if ((status = file_pipe_create(in, out, pool, pool)) != APR_SUCCESS) {
-        return status;
-    }
-
-    file_pipe_block(in, out, blocking);
-
-    return APR_SUCCESS;
+    return file_pipe_create(in, out, blocking, pool, pool);
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create_pools(apr_file_t **in,
-        apr_file_t **out, apr_int32_t blocking, apr_pool_t *pool_in, apr_pool_t *pool_out)
+                                                     apr_file_t **out,
+                                                     apr_int32_t blocking,
+                                                     apr_pool_t *pool_in,
+                                                     apr_pool_t *pool_out)
 {
-    apr_status_t status;
-
-    if ((status = file_pipe_create(in, out, pool_in, pool_out)) != APR_SUCCESS) {
-        return status;
-    }
-
-    file_pipe_block(in, out, blocking);
-
-    return APR_SUCCESS;
+    return file_pipe_create(in, out, blocking, pool_in, pool_out);
 }
 
 APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, 

Modified: apr/apr/trunk/file_io/win32/pipe.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/pipe.c?rev=1809757&r1=1809756&r2=1809757&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/pipe.c (original)
+++ apr/apr/trunk/file_io/win32/pipe.c Tue Sep 26 15:37:42 2017
@@ -63,27 +63,11 @@ APR_DECLARE(apr_status_t) apr_file_pipe_
     return APR_SUCCESS;
 }
 
-APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
-                                               apr_file_t **out,
-                                               apr_pool_t *p)
-{
-    /* Unix creates full blocking pipes. */
-    return apr_file_pipe_create_pools(in, out, APR_FULL_BLOCK, p, p);
-}
-
-APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in,
-                                                  apr_file_t **out,
-                                                  apr_int32_t blocking,
-                                                  apr_pool_t *p)
-{
-    return apr_file_pipe_create_pools(in, out, blocking, p, p);
-}
-
-APR_DECLARE(apr_status_t) apr_file_pipe_create_pools(apr_file_t **in,
-                                                     apr_file_t **out,
-                                                     apr_int32_t blocking,
-                                                     apr_pool_t *pool_in,
-                                                     apr_pool_t *pool_out)
+static apr_status_t file_pipe_create(apr_file_t **in,
+                                     apr_file_t **out,
+                                     apr_int32_t blocking,
+                                     apr_pool_t *pool_in,
+                                     apr_pool_t *pool_out)
 {
 #ifdef _WIN32_WCE
     return APR_ENOTIMPL;
@@ -224,6 +208,30 @@ APR_DECLARE(apr_status_t) apr_file_pipe_
 #endif /* _WIN32_WCE */
 }
 
+APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
+                                               apr_file_t **out,
+                                               apr_pool_t *pool)
+{
+    /* Default is full blocking pipes. */
+    return file_pipe_create(in, out, APR_FULL_BLOCK, pool, pool);
+}
+
+APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in,
+                                                  apr_file_t **out,
+                                                  apr_int32_t blocking,
+                                                  apr_pool_t *pool)
+{
+    return file_pipe_create(in, out, blocking, pool, pool);
+}
+
+APR_DECLARE(apr_status_t) apr_file_pipe_create_pools(apr_file_t **in,
+                                                     apr_file_t **out,
+                                                     apr_int32_t blocking,
+                                                     apr_pool_t *pool_in,
+                                                     apr_pool_t *pool_out)
+{
+    return file_pipe_create(in, out, blocking, pool_in, pool_out);
+}
 
 APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename,
                                                     apr_fileperms_t perm,



Mime
View raw message