Re: thread polling for timestamp on socket's error queue doesn't wake up

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

 



2017-11-10 14:39 GMT-02:00, Ricardo Biehl <rbpoficial@xxxxxxxxx>:
> I've notice that polling for timestamp in socket's error queue from a
> thread that hasn't sended the packet results in not waking the polling thread
> when an event arrives.

Not sure my statement was completely true because there is at least one case
where poll() returns. It returns POLLERR when the event requested is POLLIN.
However it doesn't return when event requested is POLLERR.

P.S.: I know POLLERR is ignored. I use it just to make the code clearer :-)

Some strace ...

Let's say thread A send packets and thread B poll() on socket's error queue for
timestamps of packets thread A has sent.

When thread B poll with pfd.events = POLLERR poll() returns in first call, but
in following calls it simply doesn't return:

[thread  A] sendto(3, "a", 1, 0, {sa_family=AF_INET, sin_port=htons(8080),
                   sin_addr=inet_addr("127.0.0.1")}, 16 <unfinished ...>
[thread  B] <... set_robust_list resumed> ) = 0
[thread  A] <... sendto resumed> )      = 1
[thread  B] poll([{fd=3, events=POLLERR}], 1, -1 <unfinished ...>
[thread  A] nanosleep({tv_sec=1, tv_nsec=0},  <unfinished ...>
[thread  B] <... poll resumed> )        = 1 ([{fd=3, revents=POLLERR}])
[thread  B] recvfrom(3, "\0", 1, MSG_ERRQUEUE, NULL, NULL) = 1
[thread  B] recvfrom(3, 0x7fa3de98ef1f, 1, MSG_ERRQUEUE, NULL, NULL) = -1 EAGAIN
            (Resource temporarily unavailable)
[thread  B] poll([{fd=3, events=POLLERR}], 1, -1 <unfinished ...>
[thread  A] <... nanosleep resumed> 0x7ffec7cc2970) = 0
[thread  A] sendto(3, "a", 1, 0, {sa_family=AF_INET, sin_port=htons(8080),
                   sin_addr=inet_addr("127.0.0.1")}, 16) = 1
[thread  A] nanosleep({tv_sec=1, tv_nsec=0}, 0x7ffec7cc2970) = 0
[thread  A] sendto(3, "a", 1, 0, {sa_family=AF_INET, sin_port=htons(8080),
                   sin_addr=inet_addr("127.0.0.1")}, 16) = 1
[thread  A] nanosleep({tv_sec=1, tv_nsec=0}, 0x7ffec7cc2970) = 0

----------------------------

When pfd.events = POLLIN we wake up after every packet thread A has sent:

[thread  A] sendto(3, "a", 1, 0, {sa_family=AF_INET, sin_port=htons(8080),
                   sin_addr=inet_addr("127.0.0.1")}, 16 <unfinished ...>
[thread  B] <... set_robust_list resumed> ) = 0
[thread  A] <... sendto resumed> )      = 1
[thread  B] poll([{fd=3, events=POLLIN}], 1, -1 <unfinished ...>
[thread  A] nanosleep({tv_sec=1, tv_nsec=0},  <unfinished ...>
[thread  B] <... poll resumed> )        = 1 ([{fd=3, revents=POLLERR}])
[thread  B] recvfrom(3, "\0", 1, MSG_ERRQUEUE, NULL, NULL) = 1
[thread  B] recvfrom(3, 0x7f7ac2370f1f, 1, MSG_ERRQUEUE, NULL, NULL) = -1 EAGAIN
            (Resource temporarily unavailable)
[thread  B] poll([{fd=3, events=POLLIN}], 1, -1 <unfinished ...>
[thread  A] <... nanosleep resumed> 0x7ffe56cfaa60) = 0
[thread  A] sendto(3, "a", 1, 0, {sa_family=AF_INET, sin_port=htons(8080),
                   sin_addr=inet_addr("127.0.0.1")}, 16 <unfinished ...>
[thread  B] <... poll resumed> )        = 1 ([{fd=3, revents=POLLERR}])
[thread  A] <... sendto resumed> )      = 1

----------------------------

--
Ricardo Biehl Pasquali

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux