[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] std::threads



Thanks Azat, I got the problem. It is the lock and unlock. In my code I return before unlock (as follows). And an interesting thing is when I call bufferevent_lock(bev_) again it doesn't block and can return. It seems the blocking happens inside libevent. So I take a long time to find it out. Thanks!

// Get the lengh a write buf
int Connection::GetWriteBufferLen() {
    /*
     * Locking the bufferevent with this function will
     * lock its associated evbuffersas well
     */
    bufferevent_lock(bev_);
    struct evbuffer *output = bufferevent_get_output(bev_);
    return evbuffer_get_length(output);
    bufferevent_unlock(bev_);
}

On 03/20/2016 05:21 AM, Azat Khuzhin wrote:
On Sat, Mar 19, 2016 at 10:36:29AM -0400, Michael wrote:
If I replace the thread code, and it works. It seems somewhere has problem
with multiple threads.
What do you mean by 'replace the thread code'?

I tried to use pthread to work with libevent. But the server can't send
out data after recving a message. The detail is:
Can you provide a minimal sample that I can compile?
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.