chrisboulton / php-resque

PHP port of resque (Workers and Queueing)
MIT License
3.43k stars 759 forks source link

gethostname() doesn't work on Amazon's EC2 #226

Closed andrewbrereton closed 8 years ago

danhunsaker commented 9 years ago

There has to be a better way to handle this than simply dropping the better option altogether. Can you give us some more detail on what "doesn't work" actually means?

cameronmurphy commented 9 years ago

Amazon EC2 instances have hostnames that are very long. This particular instance's hostname is 63 characters long.

php > var_dump(gethostname());
PHP Warning:  gethostname(): unable to fetch host [36]: File name too long in php shell code on line 1
bool(false)
danhunsaker commented 9 years ago

Not finding any info on why we should prefer one over the other, so this change is probably our best bet after all (the alternative being to check whether $hostname is false, and falling back to php_uname() if it is, which feels overly complex). It does, however, sound like a good candidate for a bug report. "Too long" seems like a terrible reason to fail here.

Until the AWS/PHP bug is fixed and/or someone comes in with a reason we should use gethostname() at all, I'm giving this one my :+1:

auroraeosrose commented 9 years ago

http://lxr.php.net/xref/PHP_5_6/ext/standard/dns.c#226 that error was not put in there for fun - it's protection for broken systems against the GHOST vulnerability

This is NOT a bug in PHP at all - it's an issue with gethostbyname in the C code and amazon's really long names :)