[vlc-commits] modules: use vlc_write() where appropriate

Rémi Denis-Courmont git at videolan.org
Wed Jun 3 19:25:28 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun  3 20:25:04 2015 +0300| [e7c7f4757c1c90a6cecb2a9189f99a84392d292b] | committer: Rémi Denis-Courmont

modules: use vlc_write() where appropriate

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e7c7f4757c1c90a6cecb2a9189f99a84392d292b
---

 modules/access_output/file.c                       |   21 +-------------------
 modules/access_output/livehttp.c                   |    6 ++++--
 modules/lua/libs/net.c                             |    2 +-
 .../video_filter/dynamicoverlay/dynamicoverlay.c   |    4 ++--
 4 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/modules/access_output/file.c b/modules/access_output/file.c
index 7b643f6..1705dc5 100644
--- a/modules/access_output/file.c
+++ b/modules/access_output/file.c
@@ -106,16 +106,10 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
     return i_write;
 }
 
-#if (_POSIX_REALTIME_SIGNALS > 0)
 static ssize_t WritePipe(sout_access_out_t *access, block_t *block)
 {
     int fd = (intptr_t)access->p_sys;
     ssize_t total = 0;
-    sigset_t set, oldset;
-
-    sigemptyset(&set);
-    sigaddset(&set, SIGPIPE);
-    pthread_sigmask(SIG_BLOCK, &set, &oldset);
 
     while (block != NULL)
     {
@@ -128,19 +122,12 @@ static ssize_t WritePipe(sout_access_out_t *access, block_t *block)
         }
 
         /* TODO: vectorized I/O with writev() */
-        ssize_t val = write(fd, block->p_buffer, block->i_buffer);
+        ssize_t val = vlc_write(fd, block->p_buffer, block->i_buffer);
         if (val < 0)
         {
             if (errno == EINTR)
                 continue;
 
-            if (errno == EPIPE)
-            {
-                siginfo_t info;
-                struct timespec ts = { 0, 0 };
-                while (sigtimedwait(&set, &info, &ts) > 0);
-            }
-
             block_ChainRelease(block);
             msg_Err(access, "cannot write: %s", vlc_strerror_c(errno));
             total = -1;
@@ -154,14 +141,8 @@ static ssize_t WritePipe(sout_access_out_t *access, block_t *block)
         block->i_buffer -= val;
     }
 
-    if (!sigismember(&oldset, SIGPIPE))
-        pthread_sigmask(SIG_SETMASK, &oldset, NULL);
-
     return total;
 }
-#else
-# define WritePipe Write
-#endif
 
 #ifdef S_ISSOCK
 static ssize_t Send(sout_access_out_t *access, block_t *block)
diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index 7a51ac8..0167d3b 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -721,7 +721,8 @@ static void closeCurrentSegment( sout_access_out_t *p_access, sout_access_out_sy
             if( err ) {
                msg_Err( p_access, "Couldn't encrypt 16 bytes: %s", gpg_strerror(err) );
             } else {
-            int ret = write( p_sys->i_handle, p_sys->stuffing_bytes, 16 );
+
+            int ret = vlc_write( p_sys->i_handle, p_sys->stuffing_bytes, 16 );
             if( ret != 16 )
                 msg_Err( p_access, "Couldn't write 16 bytes" );
             }
@@ -984,7 +985,8 @@ static ssize_t writeSegment( sout_access_out_t *p_access )
             crypted=true;
 
         }
-        ssize_t val = write( p_sys->i_handle, output->p_buffer, output->i_buffer );
+
+        ssize_t val = vlc_write( p_sys->i_handle, output->p_buffer, output->i_buffer );
         if ( val == -1 )
         {
            if ( errno == EINTR )
diff --git a/modules/lua/libs/net.c b/modules/lua/libs/net.c
index f34c010..00905ce 100644
--- a/modules/lua/libs/net.c
+++ b/modules/lua/libs/net.c
@@ -388,7 +388,7 @@ static int vlclua_fd_write( lua_State *L )
     const char *psz_buffer = luaL_checklstring( L, 2, &i_len );
 
     i_len = luaL_optint( L, 3, i_len );
-    lua_pushinteger( L, (fd != -1) ? write( fd, psz_buffer, i_len ) : -1 );
+    lua_pushinteger( L, (fd != -1) ? vlc_write( fd, psz_buffer, i_len ) : -1 );
     return 1;
 }
 
diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay.c b/modules/video_filter/dynamicoverlay/dynamicoverlay.c
index 3189808..1a2f0ab 100644
--- a/modules/video_filter/dynamicoverlay/dynamicoverlay.c
+++ b/modules/video_filter/dynamicoverlay/dynamicoverlay.c
@@ -315,8 +315,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     /* Try emptying the output buffer */
     if( p_sys->i_outputfd != -1 )
     {
-        ssize_t i_len = write( p_sys->i_outputfd, p_sys->output.p_begin,
-                              p_sys->output.i_length );
+        ssize_t i_len = vlc_write( p_sys->i_outputfd, p_sys->output.p_begin,
+                                   p_sys->output.i_length );
         if( i_len == -1 )
         {
             /* We hit an error */



More information about the vlc-commits mailing list