vijay mishra | 9 May 10:43 2016
Picon

Re: Re: Regarding broken connection when using libevent with redsocks in android M OS

Hi Azat,
   The problem is seen with libevent version 2-1-5 also.
Actually in bufferevent_ratelim.c, we are using MAX_TO_READ_EVER &  MAX_TO_WRITE_EVER buffer sizes set to 16387.

When we try to use bigger buffer sizes here... Say 32MB or 16 MB,  we are facing the issue that playstore start - stop-start hangs the whole data connection. Even other applications are not able to use redsocks new clients.

But with lesser values as is there by default -  16387,this issue is not seen. But the internet speed will be lesser. We are using higher values so as to get higher speeds (better throughput).

Our understanding is that due to these high values of buffersizes, libevent is getting stuck somewhere.

Can you point us to what might the problem area be?

BR,
Vijay

On 9 May 2016 04:51, "Azat Khuzhin" <a3at.mail <at> gmail.com> wrote:
On Sat, May 07, 2016 at 02:08:35PM +0530, vijay mishra wrote:
> Dear All,
>
> In attempt to fix this problem, we ported the latest libevent beta release
> (2-1-15, beta release) and with that , this issue is resolved but we are

Hi,

I guess you meant *2.1.5*?

> not able to find which exact commit in the latest libevent might be solving
> this issue
>
> Can anyone here help us identify the commit which may have had this issue
> fixed.
>
> PS: in stable release version 2-0-22,the issue was seen. So we suspect some
> commit after that is fixing this issue.

There are a lot of changes between 2.0.22 and 2.1.5, and I'm not even
sure because of which layer this can be, maybe you can do some
bisecting?

Thanks,
Azat.
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.
vijay mishra | 7 May 04:04 2016
Picon

Regarding broken connection when using libevent with redsocks in android M OS

Hi All.


  I was wondering if anyone here has tried libevent/redsocks combinatin in android latest versions.
We were using redsocks + libevent for data redirection to our proxy in Android L version but since we have moved to android M version we are getting a very strange issue.

   The problem is that when we install-stop-install-stop in the playstore, the device gets stuck, and NO applications can use data further.

 The reason is that we are not seeing the event generated from libevent for redsocks to read any new client connection once we do that insall-stop-install.


we are using libevent 2-0-22 stable release, but we have seen this issue  using previous libevent versions(2-0-21)  also.


 Looks like some read/write event issue in libevent.

Please help if someone has seen such behaviour in other cases also

Akhilesh Shukla | 20 Apr 07:53 2016
Picon

libevent conflict on Centos6.7

Hi,

I have nfs-utils installed on system which has dependancy on libevent 1.4 , now with new requirement I need to install pgbouncer1.7 which have depdendancy on libevent-2.x version. Centos 6.7 updates doesn't have the libevent-2.x version publish. Its only available with Centos7. 

Is there any support issue with libevent-2.x on version lower that Centos7 ? 

To resolve this I am looking for below two appraoches:

1.  Build libevent-2.x version on centos 6.7 and upgrade to libevent-2.x version on my system.

     Do you see any issues while using libevent-2 with centos6.7 ?

2. Use libevent-1.4 and libevent-2.x in parallel by rebuilding and renaming libevent-2.x as     
     mylibevent-2.x.
     It looks like the source files are different names for both libevent version and should not be a problem if i use both version together on by system.



--
Thanks,

Akhilesh Kumar Shukla

Jan Heylen | 18 Apr 16:34 2016
Picon
Gravatar

pkgconfig libevent_core

Hi,

is there a reason libevent_core.so has no pkg-config file generated in
Makefile.am? (like libevent.pc, libevent_pthreads.pc,
libevent_openssl.pc)

best regards,

Jan
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

vijay mishra | 8 Apr 13:51 2016
Picon

Regarding Libevent Crash Issue

Dear Lib-event enthusiasts, 

I am a beginner and I am using libevent with redsocks.

 Actually we are struggling with a crash in libevent.
  I was wondering if that is already reported to soem of you guys and someone have some fix for the same . It will be a great hep if you can suggest some solutions to this crash.

The details of this crash are as below :-


Crash type as seen in the Logs

signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7fa2cd2210

backtrace:
AM write failed: Broken pipe


Using debug symbols we were able to get the stack trace of the function calls. The stack trace for this issue is as below :-



evbuffer_run_callbacks
redsocks/android/jni/libevent/buffer.c:486

evbuffer_read
redsocks/android/jni/libevent/buffer.c:2268

bufferevent_readcb
redsocks/android/jni/libevent/bufferevent_sock.c:165

event_process_active_single_queue
redsocks/android/jni/libevent/event.c:1350

main
redsocks/android/jni/../../main.c:154



As we can see from above that the problem lies with evbuffer_run_callbacks() function at line 486, I am pasting the function code snippet below with the Problem Line => highlighted

Code Snippet:

static void
evbuffer_run_callbacks(struct evbuffer *buffer, int running_deferred)
{
struct evbuffer_cb_entry *cbent, *next;
struct evbuffer_cb_info info;
size_t new_size;
ev_uint32_t mask, masked_val;
int clear = 1;

if (running_deferred) {
mask = EVBUFFER_CB_NODEFER|EVBUFFER_CB_ENABLED;
masked_val = EVBUFFER_CB_ENABLED;
} else if (buffer->deferred_cbs) {
mask = EVBUFFER_CB_NODEFER|EVBUFFER_CB_ENABLED;
masked_val = EVBUFFER_CB_NODEFER|EVBUFFER_CB_ENABLED;
/* Don't zero-out n_add/n_del, since the deferred callbacks
   will want to see them. */
clear = 0;
} else {
mask = EVBUFFER_CB_ENABLED;
masked_val = EVBUFFER_CB_ENABLED;
}

ASSERT_EVBUFFER_LOCKED(buffer);

if (TAILQ_EMPTY(&buffer->callbacks)) {
buffer->n_add_for_cb = buffer->n_del_for_cb = 0;
return;
}
if (buffer->n_add_for_cb == 0 && buffer->n_del_for_cb == 0)
return;

new_size = buffer->total_len;
info.orig_size = new_size + buffer->n_del_for_cb - buffer->n_add_for_cb;
info.n_added = buffer->n_add_for_cb;
info.n_deleted = buffer->n_del_for_cb;
if (clear) {
buffer->n_add_for_cb = 0;
buffer->n_del_for_cb = 0;
}
for (cbent = TAILQ_FIRST(&buffer->callbacks);
     cbent != TAILQ_END(&buffer->callbacks);
     cbent = next) {
/* Get the 'next' pointer now in case this callback decides
 * to remove itself or something. */
next = TAILQ_NEXT(cbent, next);

if ((cbent->flags & mask) != masked_val)
continue;

if ((cbent->flags & EVBUFFER_CB_OBSOLETE))
Problem Line => cbent->cb.cb_obsolete(buffer,
    info.orig_size, new_size, cbent->cbarg);
else
cbent->cb.cb_func(buffer, &info, cbent->cbarg);
}
}



It will a great help if anyone of you can suggest a solution from your previous experience(if already encountered such a problem)  or from your expertise.


Thanks and Regards
enggatwork(Vijay Mishra)
Tim Chou | 23 Mar 23:31 2016
Picon

Add multiples bufferevents on one base then lead to some errors.

Hi all,

Sorry to disturb you. 
I'm writing a server. I plan to use one thread serving ten connections.
I use bufferevent_setcb to register 10 sockets to one base. I also use a global variable to count the number.

I think I can register the bufferevent on one base before I start a pthread to dispatch().
However, I always get the error: [err] event_queue_insert: 0x146dfc8(fd 32) already on queue 2

If I create one thread for one base with only one bufferevent, then the program works well.

Does anyone help me?
Looking forward to your replies.

Thanks,
Fang

Below is my code. 

on_accept(){
...
  evutil_make_socket_nonblocking(client_fd);

  if (num_dist==0) {
    evbase=event_base_new();
  }
  /* Create a buffer event. */
  bev = malloc(sizeof(struct bufferevent));
  bev = bufferevent_socket_new(evbase, client_fd, BEV_OPT_CLOSE_ON_FREE);

  bufferevent_setcb(bev, buffered_on_read, buffered_on_write, NULL, NULL);

  bufferevent_enable(bev, EV_READ|EV_WRITE|EV_PERSIST);

  num_dist++;
  if (num_dist==10) {
  tid=malloc(sizeof(pthread_t));
  pthread_mutex_lock(&mutex);
  total_thread++;
  printf("%d thread creates.\n",total_thread);
  pthread_mutex_unlock(&mutex);
  pthread_create(&tid, NULL, &server_job_function, (void *) evbase);
  num_dist=0;
  }

}
Michael | 20 Mar 15:54 2016
Picon

Handling the connection close

Hi all,

I want to ask what should I do when the connection is closed while I am 
sending or recving data. For example the connection is closed by the 
server explicitly or because the server is down, when the client is 
still sending data or recving data. For libevent, if the connection is 
closed, event callback is invoked. But in this callback what should we 
do? Is there any common practice?

(Any useful code can be directly filled in the following function)

Thanks!

void Connection::EventCb(struct bufferevent *bev, short events, void *ctx) {

     Connection* conn = (Connection*)ctx;
     assert(conn != NULL && bev != NULL);

     if (events & BEV_EVENT_ERROR) {

         LOG_TRACE("Error from client bufferevent: 
%s",evutil_socket_error_to_string(EVUTIL_SOCKET_ERROR()));

         // tell the client send error, and the client should send again 
or do some other things
         if (conn->GetStatus() == SENDING) {
             LOG_TRACE("Send error");
             // TODO: let the client know
         }

         conn->Close();
     }

     // The other side explicitly closes the connection
     if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) {

         // This means server explicitly closes the connection
         LOG_TRACE("ClientEventCb: 
%s",evutil_socket_error_to_string(EVUTIL_SOCKET_ERROR())); // the error 
string is "SUCCESS"

         // free the buffer event
         conn->Close();
     }
}
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Jan Heylen | 20 Mar 10:58 2016
Picon
Gravatar

deferred callbacks and evbuffer cleanup_cb

Hi,

I'm trying to use evbuffers, cleanup_cb, and the deferred callbacks.

some background:
* using (tcp) sockets
* sending data over the socket: in first place try to write
(evbuffer_write), if you get 'wouldblock' postpone the write by using
bufferevent_write_buffer. Main reason is we don't need to keep the
user's data in most cases and the dat is send immediatly.
* after sending data, a 'send cb' should be called to the user who
wanted to send something.

Now, when looking at the best way to get the cleanup happening (and a
mechanism to let the user know his data is send), I was looking at
both evbuffer callbacks and the evbuffer cleanup_cb.
I'm thinking on using the cleanup_cb, as it is only called when the
chain, the actual data, gets freed, so I can be sure the data is out.
With evbuffer callbacks, the original evbuffer gets drained upon call
to bufferevent_write_buffer already, and not when the data itself is
really 'out', so that means, I have to make a distinction.

However, If I look at the code, these cleanup_cbs are not and cannot
be 'deferred'. So in the first place, when using evbuffer_write, the
cleanup_cb will happen on the stack, and so also my 'data is send'
callback, would happen on stack (and so cb will happen before the
sending data function returns).

Questions:
* thinking about the 2 different paths on getting data out,
(evbuffer_write and postponed via bufferevent_write_buffer), what
would be the best mechanism to get the 'all data is out' cb mechanism
working for them both?
* Is it a design choice to not defer the cleanup_cb, or would it make
sense to add it?

kind regards,

Jan Heylen
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Michael | 15 Mar 16:57 2016
Picon

std::threads

Hi All,

This is Michael from CMU. I am currently using libevent in our database 
system (https://github.com/cmu-db/peloton/wiki) to let the cluster nodes 
to communicate with each other.

I want to ask how can I use multiple std::threads  on the same 
event_base. For example, a server has a  event_base. When a new 
connection coming, the server creates a std::thread with a socket_event, 
and puts the socket_event into the event_base. If there are ten 
connections, there are ten std::threads sharing the same event_base. 
(Each threads has it own socket_event to recv and send data).

Can I implement that? Is there an example?

I appreciate your help!

Best,
Michael
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Himanshu S | 10 Mar 01:07 2016
Picon

bufferevent_priority_set() for read/write

Hello experts,

I see there is priority set available for bufferevent using bufferevent_priority_set(). I believe this will set priority for read as well as write events. What I would like to do is prioritize one over another. How do I achieve that?  For eg, I would like to prioritize write over reads or the other way round. Is it possible to do that? 

Thanks,
-Himanshu
Simon Perreault | 28 Feb 22:49 2016
Gravatar

[PATCH] Fix filter bufferevent output reentrantness

Make the code do what the comment says it should do.
---
 bufferevent_filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bufferevent_filter.c b/bufferevent_filter.c
index 6c3ffc4..5d5f992 100644
--- a/bufferevent_filter.c
+++ b/bufferevent_filter.c
 <at>  <at>  -345,7 +345,8  <at>  <at>  be_filter_process_output(struct bufferevent_filtered *bevf,

 	/* disable the callback that calls this function
 	   when the user adds to the output buffer. */
-	evbuffer_cb_set_flags(bufev->output, bevf->outbuf_cb, 0);
+	evbuffer_cb_clear_flags(bufev->output, bevf->outbuf_cb,
+	    EVBUFFER_CB_ENABLED);

 	do {
 		int processed = 0;
--

-- 
2.5.0

***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.


Gmane