File tree Expand file tree Collapse file tree 1 file changed +20
-24
lines changed
Expand file tree Collapse file tree 1 file changed +20
-24
lines changed Original file line number Diff line number Diff line change @@ -382,32 +382,28 @@ void AConnection::onNoPollEvent(struct pollfd &) {
382382 Poll::setTimeout (timeout);
383383}
384384
385- static bool initPipes (int a[2 ], int b[2 ]) {
386- static int const fdsize = 4 ;
387- int fd[fdsize];
388- // int flags;
389-
390- if (pipe (&(fd[0 ])) == -1 ) return false ;
391- if (pipe (&(fd[2 ])) == -1 ) {
392- close (fd[0 ]);
393- close (fd[1 ]);
385+ /* *
386+ * @param pipeIn pipe to receive output of cgi
387+ * @param pipOut pipe to send data from server to cgi
388+ */
389+ static bool initPipes (int pipeIn[2 ], int pipeOut[2 ]) {
390+ if (pipe (pipeIn) == -1 ) return false ;
391+ if (pipe (pipeOut) == -1 ) {
392+ close (pipeIn[0 ]);
393+ close (pipeIn[1 ]);
394+ return false ;
395+ }
396+ int flagsIn = fcntl (pipeIn[0 ], F_GETFL, 0 );
397+ int flagsOut = fcntl (pipeOut[1 ], F_GETFL, 0 );
398+ if (flagsIn == -1 || fcntl (pipeIn[0 ], F_SETFL, flagsIn | O_NONBLOCK) == -1 ||
399+ flagsOut == -1 ||
400+ fcntl (pipeOut[1 ], F_SETFL, flagsOut | O_NONBLOCK) == -1 ) {
401+ close (pipeIn[0 ]);
402+ close (pipeIn[1 ]);
403+ close (pipeOut[0 ]);
404+ close (pipeOut[1 ]);
394405 return false ;
395406 }
396- // for (int i = 0; i < fdsize; ++i) { // TODO: Figure out why this breaks
397- // wordpress
398- // flags = fcntl(fd[i], F_GETFL, 0);
399- // if (flags == -1 || fcntl(fd[i], F_SETFL, flags | O_NONBLOCK) == -1) {
400- // close(fd[0]);
401- // close(fd[1]);
402- // close(fd[2]);
403- // close(fd[3]);
404- // return false;
405- // }
406- // }
407- a[0 ] = fd[0 ];
408- a[1 ] = fd[1 ];
409- b[0 ] = fd[2 ];
410- b[1 ] = fd[3 ];
411407 return true ;
412408}
413409
You can’t perform that action at this time.
0 commit comments