From 16f914deb5a926933d074c1a087886b1f6cd74aa Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 11 Sep 2016 19:26:05 -0300 Subject: [PATCH] Improve handling of EAGAIN, should fix 100% cpu usage issues Fixes #24 --- libyahoo-plusplus.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libyahoo-plusplus.c b/libyahoo-plusplus.c index b82fc3f..ce17471 100644 --- a/libyahoo-plusplus.c +++ b/libyahoo-plusplus.c @@ -1485,8 +1485,12 @@ yahoo_socket_got_data(gpointer userdata, PurpleSslConnection *conn, PurpleInputC return; } } - - if ((done_some_reads == FALSE && read_len <= 0 && errno != EAGAIN && errno != EINTR)) { + + if (done_some_reads == FALSE && read_len <= 0) { + if (read_len < 0 && errno == EAGAIN) { + return; + } + purple_debug_error("yahoo", "got errno %d, read_len %d from websocket thread\n", errno, read_len); if (ya->frames_since_reconnect < 2) {