Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 262125 Details for
Bug 162828
net-p2p/microdc2-0.15.6 100% CPU usage
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Dissected patch for CPU hogging from slavemode patch
0001-Fix-for-gentoo-bug-162828.patch (text/plain), 7.34 KB, created by
Stanislav Ochotnicky (RETIRED)
on 2011-02-11 14:47:04 UTC
(
hide
)
Description:
Dissected patch for CPU hogging from slavemode patch
Filename:
MIME Type:
Creator:
Stanislav Ochotnicky (RETIRED)
Created:
2011-02-11 14:47:04 UTC
Size:
7.34 KB
patch
obsolete
>From eef2676796f85a60a985136904964a56f3df60c3 Mon Sep 17 00:00:00 2001 >From: Stanislav Ochotnicky <sochotnicky@gmail.com> >Date: Fri, 11 Feb 2011 15:33:52 +0100 >Subject: [PATCH] Fix for gentoo bug 162828 > >Dissected from slavemode patch by Andrew Zabolotny >--- > src/main.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++------------ > 1 files changed, 85 insertions(+), 22 deletions(-) > >diff --git a/src/main.c b/src/main.c >index f3134d2..d46e158 100644 >--- a/src/main.c >+++ b/src/main.c >@@ -55,6 +55,15 @@ > #include "common/msgq.h" > #include "microdc.h" > >+/* Define the macro below for orphan handle checking (useful for debugging) */ >+#define CHECK_ORPHAN_HANDLES >+ >+#ifdef CHECK_ORPHAN_HANDLES >+#define IF_ORPHAN_HANDLES(x) x >+#else >+#define IF_ORPHAN_HANDLES(x) >+#endif >+ > enum { > VERSION_OPT = 256, > HELP_OPT >@@ -489,7 +498,8 @@ user_disconnect(DCUserConn *uc) > > FD_CLR(uc->get_mq->fd, &read_fds); > FD_CLR(uc->put_mq->fd, &write_fds); >- if (close(uc->get_mq->fd) != 0 || close(uc->put_mq->fd) != 0) >+ // using (close || close) here could cause one of close() to be skipped >+ if ((close(uc->get_mq->fd) | close(uc->put_mq->fd)) != 0) > warn(_("Cannot close pipe - %s\n"), errstr); > msgq_free(uc->get_mq); > uc->get_mq = NULL; >@@ -1109,9 +1119,11 @@ set_active(bool newactive, uint16_t port) > } > /* Start of disable_search. */ > if (search_socket >= 0) { >- if (close(search_socket) < 0) >+ if (close(search_socket) < 0) > warn(_("Cannot close socket - %s\n"), errstr); >- search_socket = -1; >+ FD_CLR(search_socket, &read_fds); >+ FD_CLR(search_socket, &write_fds); >+ search_socket = -1; > } > /* End of disable_search. */ > enable_search(); >@@ -1306,34 +1318,60 @@ main (int argc, char **argv) > break; > } > >- if (running && FD_ISSET(signal_pipe[0], &res_read_fds)) >- read_signal_input(); >- if (running && FD_ISSET(STDIN_FILENO, &res_read_fds)) >+ if (running && FD_ISSET(signal_pipe[0], &res_read_fds)) { >+ FD_CLR(signal_pipe[0], &res_read_fds); >+ read_signal_input(); >+ } >+ if (running && FD_ISSET(STDIN_FILENO, &res_read_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(STDIN_FILENO, &res_read_fds)); > screen_read_input(); >- if (running && listen_socket >= 0 && FD_ISSET(listen_socket, &res_read_fds)) >+ } >+ if (running && listen_socket >= 0 && FD_ISSET(listen_socket, &res_read_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(listen_socket, &res_read_fds)); > handle_listen_connection(); >- if (running && hub_socket >= 0 && FD_ISSET(hub_socket, &res_read_fds)) >+ } >+ if (running && hub_socket >= 0 && FD_ISSET(hub_socket, &res_read_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(hub_socket, &res_read_fds)); > hub_input_available(); >- if (running && hub_socket >= 0 && FD_ISSET(hub_socket, &res_write_fds)) >+ } >+ if (running && hub_socket >= 0 && FD_ISSET(hub_socket, &res_write_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(hub_socket, &res_write_fds)); > hub_now_writable(); >+ } > if (running) > check_hub_activity(); >- if (running && search_socket >= 0 && FD_ISSET(search_socket, &res_read_fds)) >+ if (running && search_socket >= 0 && FD_ISSET(search_socket, &res_read_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(search_socket, &res_read_fds)); > search_input_available(); >- if (running && search_socket >= 0 && FD_ISSET(search_socket, &res_write_fds)) >+ } >+ if (running && search_socket >= 0 && FD_ISSET(search_socket, &res_write_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(search_socket, &res_write_fds)); > search_now_writable(); >- if (running && FD_ISSET(lookup_request_mq->fd, &res_write_fds)) >+ } >+ if (running && FD_ISSET(lookup_request_mq->fd, &res_write_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(lookup_request_mq->fd, &res_write_fds)); > lookup_request_fd_writable(); >- if (running && FD_ISSET(lookup_result_mq->fd, &res_read_fds)) >+ } >+ if (running && FD_ISSET(lookup_result_mq->fd, &res_read_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(lookup_result_mq->fd, &res_read_fds)); > lookup_result_fd_readable(); >- if (running && FD_ISSET(parse_request_mq->fd, &res_write_fds)) >+ } >+ if (running && FD_ISSET(parse_request_mq->fd, &res_write_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(parse_request_mq->fd, &res_write_fds)); > parse_request_fd_writable(); >- if (running && FD_ISSET(parse_result_mq->fd, &res_read_fds)) >+ } >+ if (running && FD_ISSET(parse_result_mq->fd, &res_read_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(parse_result_mq->fd, &res_read_fds)); > parse_result_fd_readable(); >- if (running && FD_ISSET(update_request_mq->fd, &res_write_fds)) >+ } >+ if (running && FD_ISSET(update_request_mq->fd, &res_write_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(update_request_mq->fd, &res_write_fds)); > update_request_fd_writable(); >- if (running && FD_ISSET(update_result_mq->fd, &res_read_fds)) >+ } >+ if (running && FD_ISSET(update_result_mq->fd, &res_read_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(update_result_mq->fd, &res_read_fds)); > update_result_fd_readable(); >+ } > > if (running) { > HMapIterator it; >@@ -1341,13 +1379,36 @@ main (int argc, char **argv) > hmap_iterator(user_conns, &it); > while (running && it.has_next(&it)) { > DCUserConn *uc = it.next(&it); >- if (uc->put_mq != NULL && FD_ISSET(uc->put_mq->fd, &res_write_fds)) >+ if (uc->put_mq != NULL && FD_ISSET(uc->put_mq->fd, &res_write_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(uc->put_mq->fd, &res_write_fds)); > user_request_fd_writable(uc); >- if (uc->get_mq != NULL && FD_ISSET(uc->get_mq->fd, &res_read_fds)) >- user_result_fd_readable(uc); >+ } >+ if (uc->get_mq != NULL && FD_ISSET(uc->get_mq->fd, &res_read_fds)) { >+ IF_ORPHAN_HANDLES (FD_CLR(uc->get_mq->fd, &res_read_fds)); >+ user_result_fd_readable(uc); >+ } > } > } >- } >+ >+#ifdef CHECK_ORPHAN_HANDLES >+ /* Check for orphan file handles */ >+ { >+ int i; >+ for (i = 0; i < FD_SETSIZE; i++) { >+ if (FD_ISSET (i, &res_read_fds)) { >+ warn(_("Orphan READ file handle %d, closing\n"), i); >+ close (i); >+ FD_CLR (i, &read_fds); >+ } >+ if (FD_ISSET (i, &res_write_fds)) { >+ warn(_("Orphan WRITE file handle %d, closing\n"), i); >+ close (i); >+ FD_CLR (i, &write_fds); >+ } >+ } >+ } >+#endif >+ } > > cleanup: > >@@ -1365,6 +1426,9 @@ cleanup: > > byteq_free(search_recvq); > >+ /* Do this before freeing user_conn_unknown_free otherwise we crash */ >+ hmap_foreach_value(user_conns, user_conn_cancel); >+ > ptrv_foreach(user_conn_unknown_free, free); > ptrv_free(user_conn_unknown_free); > >@@ -1374,7 +1438,6 @@ cleanup: > ptrv_foreach(our_searches, (PtrVForeachCallback) free_search_request); > ptrv_free(our_searches); > >- hmap_foreach_value(user_conns, user_conn_cancel); > /* XXX: follow up and wait for user connections to die? */ > hmap_free(user_conns); > >-- >1.7.3.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 162828
:
202605
|
230553
| 262125