Author apexo
Recipients apexo, docs@python, pitrou
Date 2010-06-15.10:21:24
SpamBayes Score 6.43895e-05
Marked as misclassified No
Message-id <>
added a patch which fixes both issues

before releasing the GIL we take a copy of the ufds pointer and its len, erasing the ufds pointer in the poll object (to make sure nobody else fiddles with it); when we're done we either but it back into the object (when it's still NULL) or we free it

the update logic is modified as well, since the uptodate flag is not sufficient anymore, we now count up a tag for each modification of the poll dictionary and remember that tag together with the ufds pointer

the result is:
- for the single-threaded case we do little extra work (moving ufds from/to poll object)
- correct for the multi-threaded case, with slightly higher overhead (one additional call to each of malloc, update_ufd_array, free), probably worse than having one poll object per thread, but not worse than allocating a new poll object each time we want to poll

there still is potential for incorrect poll results (but not for memory corruption): when poll_register/poll_unregister are called exactly 2**32 times (or multiples thereof) while poll_poll is running, it will happily put back its outdated ufds pointer into the poll object when its done, this could be alleviated by changing tag to long long ... which is unlikely to wrap around anytime soon.
Date User Action Args
2010-06-15 10:21:30apexosetrecipients: + apexo, pitrou, docs@python
2010-06-15 10:21:30apexosetmessageid: <>
2010-06-15 10:21:28apexolinkissue8865 messages
2010-06-15 10:21:27apexocreate