SOCKETS, signal(), pthread???() and mutex???() - PROBLEMS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please, can someone help me.
I DONT KNOW MORE WHAT I NEED TO DO.

MY APPLICATION:
- I have a application the have two others Threads (using pthread) belong
the main() function running at same time.
- Each one of both threads manipulates an individual SOCKET.
- main() wait both theads to finish trying to lock a mutex already locked by
threads, allowing application to finish only when two threads finished
first.
- main() handles signals like SIGTERM, and others.

MY PROBLEM:
1) When my peer disconnects, my application (its threads) will be at some
time trying to select(), send() or recv() the sockets.
2) I ve noted that select() cannot detect socket shutdown()/closing from
peer, always returning OK and leaving in FD the socket originally being
tested by select().
3) After the wrong response from select() (we need to remember that the
sockets was closed by peer above), my threads will try to send() and/or
recv() the sockets, but exactly in this point, someone sends SIGTERM (15)
that is handled by application, rather than, returning normal errors.
4) My application requests the theads to stop, flaging a specific variable,
tested by threads.
5) When threads exit, main() function gain lock to the mutex, ending the
application.

Well, can be seeing above (item 3) that my application is being terminated
without to detect that socket was closed by peer. My application think that
the operation system sended a signal to it. (IT'S WRONG !)

PLEASE ! I need help.

Thanks,
Luciano M.


-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux