Re: A (perhaps silly) kqueue question
On 3/8/08, Vlad GALU [EMAIL PROTECTED] wrote: On 3/8/08, Robert Watson [EMAIL PROTECTED] wrote: On Fri, 7 Mar 2008, Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. I wonder if it's returning one event for the read socket buffer, and one event for the write socket buffer, since there are really two event sources for each socket? Not that this is desirable behavior, but it might explain it. If you shutdown() only read, do you get back one EOF kevent and one writable kevent? I'll try that and see. The only issue being the low frequency this symptom appears at. I'll get back to the list once I have more info. Haven't gotten to the point of testing shutdown() behavior, but here's a truss excerpt of the symptom: -- cut here -- kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) -- and here -- So two EOF are returrned for descriptor 7, and errno would be ECONNRESET. The question is now, why isn't it oneshot? Robert N M Watson Computer Laboratory University of Cambridge -- Mahnahmahnah! -- Mahnahmahnah! ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
On 3/14/08, Vlad GALU [EMAIL PROTECTED] wrote: On 3/8/08, Vlad GALU [EMAIL PROTECTED] wrote: On 3/8/08, Robert Watson [EMAIL PROTECTED] wrote: On Fri, 7 Mar 2008, Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. I wonder if it's returning one event for the read socket buffer, and one event for the write socket buffer, since there are really two event sources for each socket? Not that this is desirable behavior, but it might explain it. If you shutdown() only read, do you get back one EOF kevent and one writable kevent? I'll try that and see. The only issue being the low frequency this symptom appears at. I'll get back to the list once I have more info. Haven't gotten to the point of testing shutdown() behavior, but here's a truss excerpt of the symptom: -- cut here -- kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) -- and here -- So two EOF are returrned for descriptor 7, and errno would be ECONNRESET. The question is now, why isn't it oneshot? Ah one more thing. When EOF is caught, a handler which forcibly removes the event is called, but it keeps poping up again and again. Robert N M Watson Computer Laboratory University of Cambridge -- Mahnahmahnah! -- Mahnahmahnah! -- Mahnahmahnah! ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
In the last episode (Mar 14), Vlad GALU said: On 3/14/08, Vlad GALU [EMAIL PROTECTED] wrote: On 3/8/08, Vlad GALU [EMAIL PROTECTED] wrote: On 3/8/08, Robert Watson [EMAIL PROTECTED] wrote: On Fri, 7 Mar 2008, Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. I wonder if it's returning one event for the read socket buffer, and one event for the write socket buffer, since there are really two event sources for each socket? Not that this is desirable behavior, but it might explain it. If you shutdown() only read, do you get back one EOF kevent and one writable kevent? I'll try that and see. The only issue being the low frequency this symptom appears at. I'll get back to the list once I have more info. Haven't gotten to the point of testing shutdown() behavior, but here's a truss excerpt of the symptom: -- cut here -- kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) -- and here -- So two EOF are returrned for descriptor 7, and errno would be ECONNRESET. The question is now, why isn't it oneshot? Ah one more thing. When EOF is caught, a handler which forcibly removes the event is called, but it keeps poping up again and again. Are you sure the event is being removed? I used to have a hack that made the kernel return its current eventlist for a kqueue when you called kevent() with nchanges set to -1 (handy for placing in a program and using truss to print the result), but it has rotted. I'm attaching it in case anyone wants to make it work again. Since you got EOF status for both the read and write halves of the socket, why not just close the fd? From my reading of the manpages, unless you specified EV_ONESHOT when you added the event, events will fire until you remove them or the condition that triggers them stops. -- Dan Nelson [EMAIL PROTECTED] Index: kern_event.c === RCS file: /home/ncvs/src/sys/kern/kern_event.c,v retrieving revision 1.113 diff -u -r1.113 kern_event.c --- kern_event.c 14 Jul 2007 21:23:30 - 1.113 +++ kern_event.c 17 Jul 2007 18:10:47 - @@ -659,6 +659,41 @@ nerrors = 0; +#if 0 /* 1.92 broke this */ + if (nchanges == -1) { + /* dump our eventlist into k_ops-arg */ + int i; + int count = 0; + struct knote *kn; + error = 0; + KQ_LOCK(kq); + + /* Walk our filedescriptor lists */ + for (i = 0; i kq-kq_knlistsize count nevents; i++) { + SLIST_FOREACH(kn, kq-kq_knlist[i], kn_link) { +copyout(kn-kn_kevent, (struct kevent)k_ops-arg[count], sizeof(kn-kn_kevent)); +count++; +if (count = nevents) + break; + } + } + + /* Walk our hash tables */ + if (kq-kq_knhashmask != 0) { + for (i = 0; i = kq-kq_knhashmask count nevents; i++) { +SLIST_FOREACH(kn, kq-kq_knhash[i], kn_link) { + copyout(kn-kn_kevent, (struct kevent)k_ops-arg[count], sizeof(kn-kn_kevent)); + count++; + if (count = nevents) + break; +} + } + } + KQ_UNLOCK(kq); + td-td_retval[0] = count; + goto done; + } +#endif while (nchanges 0) { n = nchanges KQ_NEVENTS ? KQ_NEVENTS : nchanges; error = k_ops-k_copyin(k_ops-arg, keva, n); @@ -961,10 +996,12 @@ if ((kev-flags EV_DISABLE) ((kn-kn_status KN_DISABLED) == 0)) { kn-kn_status |= KN_DISABLED; + kn-kn_kevent.flags |= EV_DISABLE; } if ((kev-flags EV_ENABLE) (kn-kn_status KN_DISABLED)) { kn-kn_status = ~KN_DISABLED; + kn-kn_kevent.flags = ~EV_DISABLE; if ((kn-kn_status KN_ACTIVE) ((kn-kn_status KN_QUEUED) == 0)) knote_enqueue(kn); ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
On 3/14/08, Dan Nelson [EMAIL PROTECTED] wrote: In the last episode (Mar 14), Vlad GALU said: On 3/14/08, Vlad GALU [EMAIL PROTECTED] wrote: On 3/8/08, Vlad GALU [EMAIL PROTECTED] wrote: On 3/8/08, Robert Watson [EMAIL PROTECTED] wrote: On Fri, 7 Mar 2008, Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. I wonder if it's returning one event for the read socket buffer, and one event for the write socket buffer, since there are really two event sources for each socket? Not that this is desirable behavior, but it might explain it. If you shutdown() only read, do you get back one EOF kevent and one writable kevent? I'll try that and see. The only issue being the low frequency this symptom appears at. I'll get back to the list once I have more info. Haven't gotten to the point of testing shutdown() behavior, but here's a truss excerpt of the symptom: -- cut here -- kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2) -- and here -- So two EOF are returrned for descriptor 7, and errno would be ECONNRESET. The question is now, why isn't it oneshot? Ah one more thing. When EOF is caught, a handler which forcibly removes the event is called, but it keeps poping up again and again. Are you sure the event is being removed? I used to have a hack that made the kernel return its current eventlist for a kqueue when you called kevent() with nchanges set to -1 (handy for placing in a program and using truss to print the result), but it has rotted. I'm attaching it in case anyone wants to make it work again. Yep, I'm sure, I've just read the app logs again, we close the descriptor in the connection destructor.. Since you got EOF status for both the read and write halves of the socket, why not just close the fd? From my reading of the manpages, unless you specified EV_ONESHOT when you added the event, events will fire until you remove them or the condition that triggers them stops. -- Dan Nelson [EMAIL PROTECTED] -- Mahnahmahnah! ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
On 3/8/08, Robert Watson [EMAIL PROTECTED] wrote: On Fri, 7 Mar 2008, Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. I wonder if it's returning one event for the read socket buffer, and one event for the write socket buffer, since there are really two event sources for each socket? Not that this is desirable behavior, but it might explain it. If you shutdown() only read, do you get back one EOF kevent and one writable kevent? I'll try that and see. The only issue being the low frequency this symptom appears at. I'll get back to the list once I have more info. Robert N M Watson Computer Laboratory University of Cambridge -- Mahnahmahnah! ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
A (perhaps silly) kqueue question
I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. Thanks for your kind input. -- Mahnahmahnah! ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. Thanks for your kind input. You don't specify which version you are running Interstingly I may have seen a similar thing myself, but fixed it elsewhere. the question is a valid one.. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
On 3/7/08, Julian Elischer [EMAIL PROTECTED] wrote: Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. Thanks for your kind input. You don't specify which version you are running Ah, yes, sorry. Fresh RELENG_7. Interstingly I may have seen a similar thing myself, but fixed it elsewhere. the question is a valid one.. -- Mahnahmahnah! ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
Vlad GALU wrote: On 3/7/08, Julian Elischer [EMAIL PROTECTED] wrote: Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. Thanks for your kind input. You don't specify which version you are running Ah, yes, sorry. Fresh RELENG_7. Interstingly I may have seen a similar thing myself, but fixed it elsewhere. the question is a valid one.. Is this reproducable? Can you make this happen at will? ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
On 3/7/08, Julian Elischer [EMAIL PROTECTED] wrote: Vlad GALU wrote: On 3/7/08, Julian Elischer [EMAIL PROTECTED] wrote: Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. Thanks for your kind input. You don't specify which version you are running Ah, yes, sorry. Fresh RELENG_7. Interstingly I may have seen a similar thing myself, but fixed it elsewhere. the question is a valid one.. Is this reproducable? Can you make this happen at will? I'll try. So far we haven't been able to trigger it at will, unfortunately :( It just pops out once in a while.. -- Mahnahmahnah! ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: A (perhaps silly) kqueue question
On Fri, 7 Mar 2008, Vlad GALU wrote: I see an unusual symptom with one of our in-house applications. The main I/O loop calls kevent(), which in turn returns two events with EV_EOF error set, always for the same descriptors (they're both socket descriptors). As the man page is not pretty clear about it and I don't have my UNP copy at hand, I would like to ask the list whether the error events are supposed to be one-shot or not. I wonder if it's returning one event for the read socket buffer, and one event for the write socket buffer, since there are really two event sources for each socket? Not that this is desirable behavior, but it might explain it. If you shutdown() only read, do you get back one EOF kevent and one writable kevent? Robert N M Watson Computer Laboratory University of Cambridge ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]