@@ -83,7 +83,8 @@ private function addClientSocket( $socket ) {
83
83
84
84
function listen ( $ acceptTimeout = 60 ) {
85
85
86
- file_put_contents ( '/tmp/crusse-job-server.log ' , '' );
86
+ // Uncomment only when debugging
87
+ //file_put_contents( '/tmp/crusse-job-server.log', '' );
87
88
88
89
@unlink ( $ this ->serverSocketAddr );
89
90
@@ -192,7 +193,7 @@ private function handleReadableSockets( $sockets ) {
192
193
if ( !$ messages )
193
194
continue ;
194
195
195
- $ this ->log ( 'Buffer had ' . count ( $ messages ) .' messages ' );
196
+ // $this->log( 'Buffer had '. count( $messages ) .' messages' );
196
197
197
198
foreach ( $ messages as $ message ) {
198
199
foreach ( $ this ->callbacks as $ callback ) {
@@ -223,7 +224,7 @@ private function handleWritableSockets( $sockets ) {
223
224
throw new \Exception ( 'Could not write to socket ' );
224
225
}
225
226
226
- $ this ->log ( 'Sent ' . $ sentBytes .' b to ' . $ socketIndex );
227
+ // $this->log( 'Sent '. $sentBytes .' b to '. $socketIndex );
227
228
$ this ->writeBuffer [ $ socketIndex ] = substr ( $ buffer , $ sentBytes );
228
229
}
229
230
}
@@ -238,7 +239,7 @@ private function acceptClient() {
238
239
}
239
240
240
241
$ this ->addClientSocket ( $ socket );
241
- $ this ->log ( 'Accepted client ' . ( count ( $ this ->sockets ) - 1 ) );
242
+ // $this->log( 'Accepted client '. ( count( $this->sockets ) - 1 ) );
242
243
243
244
return $ socket ;
244
245
}
@@ -258,7 +259,7 @@ private function getMessagesFromSocket( $socket ) {
258
259
// Populate the MessageBuffer from the socket
259
260
260
261
$ data = '' ;
261
- $ dataLen = socket_recv ( $ socket , $ data , 32 * 1024 , MSG_DONTWAIT );
262
+ $ dataLen = socket_recv ( $ socket , $ data , 64 * 1024 , MSG_DONTWAIT );
262
263
263
264
// There was an error
264
265
if ( $ dataLen === false ) {
@@ -274,7 +275,7 @@ private function getMessagesFromSocket( $socket ) {
274
275
return array ();
275
276
}
276
277
277
- $ this ->log ( 'Recvd ' . $ dataLen .' b from ' . $ socketIndex );
278
+ // $this->log( 'Recvd '. $dataLen .' b from '. $socketIndex );
278
279
$ this ->populateMessageBuffer ( $ data , $ buffer );
279
280
280
281
// Get finished Message objects from the MessageBuffer
@@ -291,7 +292,7 @@ private function getMessagesFromSocket( $socket ) {
291
292
// partially) other messages' data
292
293
if ( $ overflowBytes > 0 ) {
293
294
294
- $ this ->log ( 'Recvd multiple messages from socket (overflow: ' . $ overflowBytes .' b) ' );
295
+ // $this->log( 'Recvd multiple messages from socket (overflow: '. $overflowBytes .' b)' );
295
296
296
297
$ overflow = substr ( $ buffer ->message ->body , -$ overflowBytes );
297
298
$ buffer ->message ->body .= substr ( $ buffer ->message ->body , 0 , -$ overflowBytes );
@@ -361,6 +362,9 @@ private function closeConnection( $socket ) {
361
362
362
363
private function log ( $ msg , $ socketIndex = 0 ) {
363
364
365
+ // Remove this only for debugging
366
+ return ;
367
+
364
368
static $ id = '' ;
365
369
if ( !$ id )
366
370
$ id = uniqid ();
0 commit comments