[Trac] [AllemaniACs] #35: Socket interruptible poll()

AllemaniACs trac-notifications at lists.kbsg.rwth-aachen.de
Thu Apr 17 11:51:36 CEST 2008


#35: Socket interruptible poll()
---------------------+------------------------------------------------------
 Reporter:  tim      |       Owner:  tim    
     Type:  feature  |      Status:  new    
 Priority:  major    |   Milestone:         
Component:  Fawkes   |    Keywords:  network
---------------------+------------------------------------------------------
 Currently if you poll a socket you cannot safely write to this socket in a
 multi-threaded environment. Even worse, if you want to allow this you have
 to poll with a timeout and check if data has to be written. This has two
 drawbacks:
  * The code gets less efficient. Instead of waiting blocked until there
 really is something to do you have to stop by every now and then to check
 if something else is to do.
  * You have a delay before you can write. Let's assume you have a poll
 timeout of 10ms. Then it may take up to these 10ms before a write() can
 succeed because you have to wait for the poll timeout.

 The idea to solve this is taken from the Avahi project: You open an
 internal pipe in the socket. The pipe has a file descriptor as well. This
 way you can poll for both descriptors, the socket and the pipe. If you now
 want to write you can interrupt the poll by writing to the pipe. The poll
 will return indicating not that read() is possible but that a write bas
 been requested. This solves both of the problems above. You do something
 only if tasks are actually waiting and you can interrupt the poll
 immediately.

 Code is in front of my eyes, just has to be written down and tested...

-- 
Ticket URL: <https://lechuck.informatik.rwth-aachen.de:2342/trac/ticket/35>
AllemaniACs <http://robocup.rwth-aachen.de>
AllemaniACs Trac


More information about the fawkes-trac mailing list