Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure making HTTP request to unix socket #1615

Closed
pinheadmz opened this issue Apr 10, 2024 · 2 comments · Fixed by #1616
Closed

Failure making HTTP request to unix socket #1615

pinheadmz opened this issue Apr 10, 2024 · 2 comments · Fixed by #1616

Comments

@pinheadmz
Copy link

pinheadmz commented Apr 10, 2024

Built from source on macOS:

$ git status
HEAD detached at release-2.1.12-stable

Run http server example, binding to local unix socket:

$ sample/http-server -v -U /Users/matthewzipkin/Desktop/y /

Execute request from second terminal:

$  curl -vvv --unix-socket ~/Desktop/y http://localhost/                                             

*   Trying /Users/matthewzipkin/Desktop/y:0...                                                                                                                                                              
* Connected to localhost (/Users/matthewzipkin/Desktop/y) port 80 (#0)                                                                                                                                      
> GET / HTTP/1.1                                                                                                                                                                                            
> Host: localhost                                                                                                                                                                                           
> User-Agent: curl/7.87.0                                                                                                                                                                                   
> Accept: */*                                                                                                                                                                                               
>                                                                                                                                                                                                           
* Empty reply from server                                                                                                                                                                                   
* Closing connection 0                                                                                                                                                                                      
curl: (52) Empty reply from server

the libevent http server crashes with this output:

[debug] event_add: event: 0x6000034a8038 (fd 4), EV_READ    call 0x1026ac638
Listening on </Users/matthewzipkin/Desktop/y>
[debug] event_add: event: 0x600002fa8080 (fd 2),     call 0x10251f6e8
[debug] evsig_set_handler_: evsignal (2) >= sh_old_max (0), resizing
[debug] kq_dispatch: kevent reports 1
[debug] event_active: 0x6000034a8038 (fd 4), res 2, callback 0x1026ac638
[debug] event_process_active: event: 0x6000034a8038, EV_READ   call 0x1026ac638
[err] getnameinfo failed: ai_family not supported

Looking through the code, I see that we call name_from_addr() from evhttp_get_request(). This passes the socket directly to getnameinfo() which does not support AF_UNIX.

@pinheadmz
Copy link
Author

Can't even get that far on master...

$ git rev-parse HEAD
c6e8f17541b99e8c3a089a1c6f70119d6f95db9d
$ sample/http-server -v -U /Users/matthewzipkin/Desktop/dd /
Cannot create listener: Operation not supported on socket
[debug] event_base_free_: 0 events freed

@emilengler
Copy link
Contributor

I can confirm your observation on master

emilengler added a commit to emilengler/libevent that referenced this issue Apr 12, 2024
This commit disables the property of TCP keepalive on Unix domain
sockets, because they essentially serve no purpose here, except for
causing problems on Windows and macOS systems.

Fixes libevent#1615
azat pushed a commit that referenced this issue Apr 24, 2024
This commit disables the property of TCP keepalive on Unix domain
sockets, because they essentially serve no purpose here, except for
causing problems on Windows and macOS systems.

Fixes #1615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants