amphp / dns

Async DNS resolution for PHP based on Amp.
https://amphp.org/dns
MIT License
157 stars 32 forks source link

fwrite can fail #3

Closed Danack closed 10 years ago

Danack commented 10 years ago

The fwrite here can fail, generating a notice but continues to run in a presumably bogus state.

So I guess the code so check the return value.....and possibly suppress the warning? (shakes fist at PHP's 'error' model)

Exception:

Notice: fwrite(): send of 32 bytes failed with errno=65 No route to host in /documents/projects/github/FlickrArtaxService/vendor/daverandom/addr/lib/Addr/Client.php on line 182
Call Stack
#   Time    Memory  Function    Location
1   0.0000  231824  {main}( )   ../index.php:0
2   0.0012  392856  showFlickrStatus( ) ../index.php:31
3   0.0026  498496  FlickrService\FlickrAPI\flickrTestLogin->execute( ) ../flickrBootstrap.php:65
4   0.0032  527960  FlickrService\FlickrAPI\FlickrAPI->callAPI( )   ../flickrTestLogin.php:141
5   0.0052  774976  Artax\Client->request( )    ../FlickrAPI.php:42
6   0.0052  778120  Alert\NativeReactor->tick( )    ../Client.php:53
7   0.0052  778800  Alert\NativeReactor->executeAlarms( )   ../NativeReactor.php:82
8   0.0052  778984  Alert\NativeReactor->doAlarmCallback( ) ../NativeReactor.php:122
9   0.0052  778640  Artax\Client->Artax\{closure}( )    ../NativeReactor.php:143
10  0.0052  778688  Artax\AsyncClient->request( )   ../Client.php:49
11  0.0055  802840  Artax\AsyncClient->resolveDns( )    ../AsyncClient.php:87
12  0.0055  804320  Artax\AddrDnsResolver->resolve( )   ../AsyncClient.php:354
13  0.0055  805152  Addr\Resolver->resolve( )   ../AddrDnsResolver.php:51
14  0.0068  819912  Addr\Resolver->resolveFromServer( ) ../Resolver.php:176
15  0.0068  820008  Addr\Client->resolve( ) ../Resolver.php:151
16  0.0068  821848  Addr\Client->processPendingLookup( )    ../Client.php:342
17  0.0068  825632  Addr\Client->sendRequest( ) ../Client.php:305
18  0.0076  887512  fwrite ( )  ../Client.php:182
DaveRandom commented 10 years ago

To fix: Ensure that writes are checked for success, and fail if not Open question: should a failure roll down to the next lookup in the stack or return failure immediately?

DaveRandom commented 10 years ago

Fixed in 0.2 and master