Code Monkey home page Code Monkey logo

Comments (5)

NathanFrench avatar NathanFrench commented on June 13, 2024

If you remove usleep, does it work?

from libevhtp.

gamorwang avatar gamorwang commented on June 13, 2024

I comment this usleep line, then the coredump frequency become bigger.

from libevhtp.

NathanFrench avatar NathanFrench commented on June 13, 2024

This is very very hard to reproduce with almost 0 information (your backtrace doesn't even have debug symbols, from what I see, the error is in libevent, not evhtp).

Can you please use the template:

Details

Steps or code to reproduce the problem.

Example code

#include <evhtp.h>

int
main(int argc, char ** argv)
{
    return 0;
}

Version

from libevhtp.

gamorwang avatar gamorwang commented on June 13, 2024

I have found the problem。

step1:
Let your cpu almost 100% use
step2:
remove usleep, then run my example

code:

int j = 0;
vector test_vec;

int main()
{
auto base = event_base_new();
auto ev_htp = evhtp_new(base, NULL);

evhtp_use_threads_wexit(ev_htp, [](evhtp_t * htp, evthr_t * evthr, void * arg) {
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
test_vec.push_back(j++);
}, NULL, 160, NULL);

sleep(10000);
return 0;
}

from libevhtp.

gamorwang avatar gamorwang commented on June 13, 2024

source code 1:

struct evthr_pool {
#ifdef EVTHR_SHARED_PIPE
    int rdr;
    int wdr;
#endif
    int                nthreads;
    evthr_pool_slist_t threads;
};

struct evthr {
    int             rdr;
    int             wdr;
    char            err;
    ev_t          * event;
    evbase_t      * evbase;
    pthread_mutex_t lock;
    pthread_t     * thr;
    evthr_init_cb   init_cb;
    evthr_init_cb   exit_cb;
    void          * arg;
    void          * aux;

#ifdef EVTHR_SHARED_PIPE
    int            pool_rdr;
    struct event * shared_pool_ev;
#endif
    TAILQ_ENTRY(evthr) next;
};

comment:
look at this struct, I think the pthread_mutex_t lock should put into struct evthr_pool, not put into struct evthr.

source code 2:

    pthread_mutex_lock(&thread->lock);
    printf("mutex lock addr: %p\n", &thread->lock);
    if (thread->init_cb != NULL) {
        (thread->init_cb)(thread, thread->arg);
    }
    pthread_mutex_unlock(&thread->lock);

comment:
If the lock put into evthr, then the pthread_mutex_lock(&thread->lock) has no meanings.

from libevhtp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.