Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 685180 Details for
Bug 889651
segfault in dmeventd in low memory situations
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Proposal patch for locking changes
update-dmeventd.patch (text/plain), 6.54 KB, created by
Zdenek Kabelac
on 2013-01-22 14:21:55 UTC
(
hide
)
Description:
Proposal patch for locking changes
Filename:
MIME Type:
Creator:
Zdenek Kabelac
Created:
2013-01-22 14:21:55 UTC
Size:
6.54 KB
patch
obsolete
> daemons/dmeventd/dmeventd.c | 80 +++++++++++++++++++++------------------------ > 1 file changed, 37 insertions(+), 43 deletions(-) > >diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c >index 001932d..f526497 100644 >--- a/daemons/dmeventd/dmeventd.c >+++ b/daemons/dmeventd/dmeventd.c >@@ -67,7 +67,6 @@ > #include <syslog.h> > > static volatile sig_atomic_t _exit_now = 0; /* set to '1' when signal is given to exit */ >-static volatile sig_atomic_t _thread_registries_empty = 1; /* registries are empty initially */ > > /* List (un)link macros. */ > #define LINK(x, head) dm_list_add(head, &(x)->list) >@@ -646,7 +645,7 @@ static int _event_wait(struct thread_status *thread, struct dm_task **task) > !dm_task_set_event_nr(dmt, thread->event_nr)) > goto out; > >- syslog(LOG_NOTICE, "dm_task_run event_nr %d on %p\n", thread->event_nr, thread); >+ if (thread->event_nr) syslog(LOG_NOTICE, "dm_task_run event_nr %d on %p\n", thread->event_nr, thread); > > /* > * This is so that you can break out of waiting on an event, >@@ -728,9 +727,10 @@ static void _monitor_unregister(void *arg) > if (!_do_unregister_device(thread)) > syslog(LOG_ERR, "%s: %s unregister failed\n", __func__, > thread->device.name); >- if (thread->current_task) >+ if (thread->current_task) { > dm_task_destroy(thread->current_task); >- thread->current_task = NULL; >+ thread->current_task = NULL; >+ } > > _lock_mutex(); > if (thread->events & DM_EVENT_TIMEOUT) { >@@ -750,10 +750,8 @@ static void _monitor_unregister(void *arg) > return; > } > thread->status = DM_THREAD_DONE; >- pthread_mutex_lock(&_timeout_mutex); > UNLINK_THREAD(thread); > LINK(thread, &_thread_registry_unused); >- pthread_mutex_unlock(&_timeout_mutex); > _unlock_mutex(); > } > >@@ -833,10 +831,8 @@ static void *_monitor_thread(void *arg) > _unlock_mutex(); > break; > } >- _unlock_mutex(); > > if (thread->events & thread->current_events) { >- _lock_mutex(); > thread->processing = 1; > _unlock_mutex(); > >@@ -848,6 +844,7 @@ static void *_monitor_thread(void *arg) > thread->processing = 0; > _unlock_mutex(); > } else { >+ _unlock_mutex(); > dm_task_destroy(task); > thread->current_task = NULL; > } >@@ -1002,8 +999,6 @@ static int _register_for_event(struct message_data *message_data) > goto out; > } > >- _lock_mutex(); >- > /* If creation of timeout thread fails (as it may), we fail > here completely. The client is responsible for either > retrying later or trying to register without timeout >@@ -1013,9 +1008,10 @@ static int _register_for_event(struct message_data *message_data) > if (thread_new->events & DM_EVENT_TIMEOUT) { > ret = -_register_for_timeout(thread_new); > if (ret) >- goto outth; >+ goto out; > } > >+ _lock_mutex(); > if (!(thread = _lookup_thread_status(message_data))) { > _unlock_mutex(); > >@@ -1038,8 +1034,6 @@ static int _register_for_event(struct message_data *message_data) > > /* Or event # into events bitfield. */ > thread->events |= message_data->events.field; >- >- outth: > _unlock_mutex(); > > out: >@@ -1086,18 +1080,19 @@ static int _unregister_for_event(struct message_data *message_data) > > thread->events &= ~message_data->events.field; > >- if (!(thread->events & DM_EVENT_TIMEOUT)) >+ if (!(thread->events & DM_EVENT_TIMEOUT)) { >+ _unlock_mutex(); > _unregister_for_timeout(thread); >+ _lock_mutex(); >+ } > /* > * In case there's no events to monitor on this device -> > * unlink and terminate its monitoring thread. > */ > if (!thread->events) { > syslog(LOG_ERR, "THREAD UNUSED"); >- pthread_mutex_lock(&_timeout_mutex); > UNLINK_THREAD(thread); > LINK(thread, &_thread_registry_unused); >- pthread_mutex_unlock(&_timeout_mutex); > } > _unlock_mutex(); > syslog(LOG_ERR, "THREAD DONE"); >@@ -1121,9 +1116,9 @@ static int _registered_device(struct message_data *message_data, > const char *dso = thread->dso_data->dso_name; > const char *dev = thread->device.uuid; > int r; >- unsigned events = ((thread->status == DM_THREAD_RUNNING) >- && (thread->events)) ? thread->events : thread-> >- events | DM_EVENT_REGISTRATION_PENDING; >+ unsigned events = ((thread->status == DM_THREAD_RUNNING) && >+ thread->events) ? thread->events : >+ thread->events | DM_EVENT_REGISTRATION_PENDING; > > dm_free(msg->data); > >@@ -1534,17 +1529,16 @@ static void _process_request(struct dm_event_fifos *fifos) > > static void _process_initial_registrations(void) > { >- int i = 0; >+ int i; > char *reg; > struct dm_event_daemon_message msg = { 0, 0, NULL }; > >- while ((reg = _initial_registrations[i])) { >+ for (i = 0; (reg = _initial_registrations[i]); ++i) { > msg.cmd = DM_EVENT_CMD_REGISTER_FOR_EVENT; > if ((msg.size = strlen(reg))) { > msg.data = reg; > _do_process_request(&msg); > } >- ++ i; > } > } > >@@ -1595,8 +1589,10 @@ static void _cleanup_unused_threads(void) > > if (thread->status == DM_THREAD_DONE) { > dm_list_del(l); >+ _unlock_mutex(); > join_ret = pthread_join(thread->thread, NULL); > _free_thread_status(thread); >+ _lock_mutex(); > } > } > >@@ -1638,19 +1634,7 @@ static void _init_thread_signals(void) > */ > static void _exit_handler(int sig __attribute__((unused))) > { >- /* >- * We exit when '_exit_now' is set. >- * That is, when a signal has been received. >- * >- * We can not simply set '_exit_now' unless all >- * threads are done processing. >- */ >- if (!_thread_registries_empty) { >- syslog(LOG_ERR, "There are still devices being monitored."); >- syslog(LOG_ERR, "Refusing to exit."); >- } else >- _exit_now = 1; >- >+ _exit_now = 1; > } > > #ifdef linux >@@ -1954,6 +1938,7 @@ int main(int argc, char *argv[]) > { > signed char opt; > struct dm_event_fifos fifos; >+ int nothreads; > //struct sys_log logdata = {DAEMON_NAME, LOG_DAEMON}; > > opterr = 0; >@@ -2045,16 +2030,25 @@ int main(int argc, char *argv[]) > if (_initial_registrations) > _process_initial_registrations(); > >- while (!_exit_now) { >+ for (;;) { >+ if (_exit_now) { >+ _exit_now = 0; >+ /* >+ * When '_exit_now' is set, signal has been received, >+ * but can not simply exit unless all >+ * threads are done processing. >+ */ >+ _lock_mutex(); >+ nothreads = (dm_list_empty(&_thread_registry) && >+ dm_list_empty(&_thread_registry_unused)); >+ _unlock_mutex(); >+ if (nothreads) >+ break; >+ syslog(LOG_ERR, "There are still devices being monitored."); >+ syslog(LOG_ERR, "Refusing to exit."); >+ } > _process_request(&fifos); > _cleanup_unused_threads(); >- _lock_mutex(); >- if (!dm_list_empty(&_thread_registry) >- || !dm_list_empty(&_thread_registry_unused)) >- _thread_registries_empty = 0; >- else >- _thread_registries_empty = 1; >- _unlock_mutex(); > } > > _exit_dm_lib(); >-- >1.8.1 >
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 889651
: 685180