@@ -104,26 +104,9 @@ class IRRQuery {
104
104
function _send ($ output )
105
105
{
106
106
$ this ->lastcommand = rtrim ($ output );
107
- $ count = 0 ;
108
107
// Attempt to send the command
109
108
$ r = @fwrite ($ this ->fp , $ output );
110
109
111
- while ($ r == FALSE && $ count < 3 ) {
112
- /*
113
- if the command fails, then let's clone the file handle,
114
- wait a second, reconnect, and try again. We will try this 3 times.
115
- */
116
- status (STATUS_ERROR , "IRR Query - Error on write. Re-connecting... " );
117
-
118
- // Make sure we don't leave dangling file pointers around
119
- fclose ($ this ->fp );
120
-
121
- sleep (1 );
122
- $ this ->connect ($ this ->host , $ this ->port );
123
- $ count += 1 ;
124
- $ r = @fwrite ($ this ->fp , $ output );
125
- }
126
-
127
110
if ($ r === FALSE ) {
128
111
status (STATUS_ERROR , "IRR Query - Error on write. Re-connect issue... " );
129
112
return FALSE ;
@@ -315,6 +298,17 @@ class IRRQuery {
315
298
if (($ results = $ this ->_cache_query ("origin " , $ origin )) != FALSE )
316
299
return $ results ;
317
300
301
+ /* Validate if socket connection is exists */
302
+ if (feof ($ this ->fp ) === true )
303
+ {
304
+ status (STATUS_ERROR , "get_v4_routes_by_origin socket closed. " );
305
+ fclose ($ this ->fp );
306
+ sleep (2 );
307
+ $ this ->connect ($ this ->host , $ this ->port );
308
+ status (STATUS_ERROR , "get_v4_routes_by_origin reconnecting socket. " );
309
+ }
310
+
311
+
318
312
/* Get v4 prefixes */
319
313
$ this ->_send ("!g {$ origin }\n" );
320
314
@@ -349,6 +343,16 @@ class IRRQuery {
349
343
if (($ results = $ this ->_cache_query ("origin6 " , $ origin )) != FALSE )
350
344
return $ results ;
351
345
346
+ /* Validate if socket connection is exists */
347
+ if (feof ($ this ->fp ) === true )
348
+ {
349
+ status (STATUS_ERROR , "get_v6_routes_by_origin socket closed. " );
350
+ fclose ($ this ->fp );
351
+ sleep (2 );
352
+ $ this ->connect ($ this ->host , $ this ->port );
353
+ status (STATUS_ERROR , "get_v6_routes_by_origin reconnecting socket " );
354
+ }
355
+
352
356
/* Get v6 prefixes */
353
357
$ this ->_send ("!6 {$ origin }\n" );
354
358
if (($ results = $ this ->_response ()) == FALSE )
0 commit comments