You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1、 Result
[root@bogon preeny]# LD_PRELOAD=/root/src/preeny/x86_64-redhat-linux/desock.so ./tests/sock
HI!
1234
[root@bogon preeny]#
2、 This piece of code here doesn't seem to be working。
“FILE *zomg = fdopen(s, "w");”“
The text was updated successfully, but these errors were encountered:
I think this might be a bug in the 'tests/sock.c', because the socket file is block buffered by default, and if you use fprintf to write to the socket, the characters are saved up and would not be written to the socket immediately.
The debug output of the original ./sock( only print last few lines).
//...
+++ read 5 bytes from 0 (will write to 503)
+++ wrote 5 bytes to 503 (had read from 0)
+++ shutting down desock...
+++ sending SIGINT to thread 3...
+++ readpoll() timed out on fd 503
+++ readpoll() timed out on fd 0
+++ ... sent!
+++ readpoll() timed out on fd 503
+++ ... shutdown complete!
we can observe that when shutting down desock, there is no data come from fd 503 which proves my hypothesis above.
As to resolve this problem, you can also add a line setlinebuf(zomg) before fprintf.
1、 Result
[root@bogon preeny]# LD_PRELOAD=/root/src/preeny/x86_64-redhat-linux/desock.so ./tests/sock
HI!
1234
[root@bogon preeny]#
2、 This piece of code here doesn't seem to be working。
“FILE *zomg = fdopen(s, "w");”“
The text was updated successfully, but these errors were encountered: