Oops. Thank you, Clint. First variant is exactly what i need. Don't mention my previous email. :)
2009/6/26 Clint Webb <webb.cl...@gmail.com>: > SIGPIPE happens normally because you attempt to write to a socket that has > closed. > > There are a couple of things you can do... > > 1. You can disable SIGPIPE notification. Something like: > > struct sigaction sa; > sa.sa_handler = SIG_IGN; > sa.sa_flags = 0; > if (sigemptyset(&sa.sa_mask) == -1 || sigaction(SIGPIPE, &sa, 0) == -1) { > perror("failed to ignore SIGPIPE; sigaction"); > exit(EXIT_FAILURE); > > > > } > > 2. You can check the status of the socket before you write to it. > > socklen_t err_len; > int error; > err_len = sizeof(error); > getsockopt(handle, SOL_SOCKET, SO_ERROR, &error, &err_len); > if (error != ESHUTDOWN) { > // actually, I cant remember what E code to check, > // ESHUTDOWN might not be it... you can look that up yourself. > } > > > As an aside, most people dont get this error under 'normal' conditions > because as part of their process they tend to always do a read before > attempting a write. A read would detect the closed socket, and you > wouldn't bother doing the write. You are probably doing something like > that, but when doing it rapidly, connection is closing in-between the read > and write.... hence getting the sigpipe. > > > > On Fri, Jun 26, 2009 at 3:01 PM, Rauan Maemirov <ra...@maemirov.com> wrote: >> >> Hi, all. >> I'm having issues with libevent. >> >> When I use siege or something like that, everything's ok. But when I >> open link in browser, and start to push F5 like a crazy, daemon exits. >> Valgrind shows: >> >> ... >> Process terminating with default action of signal 13 (SIGPIPE) >> ==5635== at 0x5B2BF90: write (in /lib/libc-2.9.so) >> ==5635== by 0x4E335BF: evbuffer_write (buffer.c:414) >> ==5635== by 0x4E38819: evhttp_write (http.c:685) >> ==5635== by 0x4E33297: event_base_loop (event.c:392) >> ==5635== by 0x402E5F: main (myapp.c:283) // here goes event_dispatch() >> --5879-- Discarding syms at 0x91db2e0-0x91e0498 in >> /lib/libnss_compat-2.9.so due to munmap() >> --5879-- Discarding syms at 0x93e5040-0x93eb408 in >> /lib/libnss_nis-2.9.so due to munmap() >> --5879-- Discarding syms at 0x95f0020-0x95f7c48 in >> /lib/libnss_files-2.9.so due to munmap() >> ... >> >> I deem, it's because of interrupted connections. How should I handle it? >> _______________________________________________ >> Libevent-users mailing list >> Libevent-users@monkey.org >> http://monkeymail.org/mailman/listinfo/libevent-users > > > > -- > "Be excellent to each other" > _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users