Ticket #35 (new feature)

Opened 4 years ago

Socket interruptible poll()

Reported by: tim Owned by: tim
Priority: major Milestone:
Component: Fawkes Version:
Keywords: network Cc:
Git Branch:

Description

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...

Note: See TracTickets for help on using tickets.

This list contains all users that will be notified about changes made to this ticket.

These roles will be notified: Reporter, Subscriber, Participant

  • Fawkes Trac List(Always)
  • Tim Niemueller(Reporter, Owner)