Skip to main content
gamedev.net
🔒 Locked

socket close problem

Started by mhmdanger 0 replies 450+ views
Original Post
mhmdanger
mhmdanger
first my os is linux 2.6 kernel. i use two threads in my network code, one for read(), the other for write(). but the problem is, when the read thread is in the read() on fd1 and at this time clock interrupt then schedule happened(perhaps the read is copying data from kernel to user's buffer at this moment,but not finished), now the write tread is runing, and for some case it close fd1, then what will happen? thanks!
hplus0603
hplus0603
If some system call is interrupted by a signal, then EINTR is returned by that system call. If you later try to read again from a file descriptor that has been closed, you'll get EBADF back.

Note that the design you're describing sounds poor from a synchronization point of view. You might have some significant problems actually debugging that.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.