@@ -80,16 +80,17 @@ static void error_clnt(const char *fmt, ...)
8080 die ("sent error to the client: %s" , buf );
8181}
8282
83- static void process_input (int child_fd , int band )
83+ static ssize_t process_input (int child_fd , int band )
8484{
8585 char buf [16384 ];
8686 ssize_t sz = read (child_fd , buf , sizeof (buf ));
8787 if (sz < 0 ) {
8888 if (errno != EAGAIN && errno != EINTR )
8989 error_clnt ("read error: %s\n" , strerror (errno ));
90- return ;
90+ return sz ;
9191 }
9292 send_sideband (1 , band , buf , sz , LARGE_PACKET_MAX );
93+ return sz ;
9394}
9495
9596int cmd_upload_archive (int argc , const char * * argv , const char * prefix )
@@ -131,6 +132,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
131132
132133 while (1 ) {
133134 struct pollfd pfd [2 ];
135+ ssize_t processed [2 ] = { 0 , 0 };
134136 int status ;
135137
136138 pfd [0 ].fd = fd1 [0 ];
@@ -147,12 +149,12 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
147149 }
148150 if (pfd [0 ].revents & POLLIN )
149151 /* Data stream ready */
150- process_input (pfd [0 ].fd , 1 );
152+ processed [ 0 ] = process_input (pfd [0 ].fd , 1 );
151153 if (pfd [1 ].revents & POLLIN )
152154 /* Status stream ready */
153- process_input (pfd [1 ].fd , 2 );
155+ processed [ 1 ] = process_input (pfd [1 ].fd , 2 );
154156 /* Always finish to read data when available */
155- if (( pfd [0 ]. revents | pfd [1 ]. revents ) & POLLIN )
157+ if (processed [0 ] || processed [1 ])
156158 continue ;
157159
158160 if (waitpid (writer , & status , 0 ) < 0 )
0 commit comments