Skip to content

Sometimes deadlocks on tlog_exit() in threaded app #16

@gocowim

Description

@gocowim

Right now I can only tell that my application sometimes doesn't end because tlog_exit() doesn't return.

If I find a simple code to reproduce it, I will add it here, of course...

The simplified pseudo code looks like that:

void signal_handler( signal ) {case {SIGINT, SIGTERM: server_stop = 1;} }
void *thread() { while (server_stop != 1) { do stuff; tlog(somtehing); }
main() {
    signal(SIGINT, handle_signal);
    signal(SIGTERM, handle_signal);

    tlog_init(logfile, 1M, 4, 0, TLOG_SCREEN_COLOR);
    for (i = 0 .. N) {
        pthread_create(thread);
    }

   while (server_stop != 1) { do something; sleep() }

    for (i = 0 .. N) {
        pthread_join(thread);
    }
    tlog("DONE");
    tlog_exit();
}

lsof -t /path/to/logfile shows that the process still has the file open.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions