Opera Wang | 19 Apr 14:24 2016
Picon
Gravatar

Find active watchers

Hi,
    I'm currently using the Perl binding EV, together with modules like IO::Stream, IO::AIO, Promises, & Mojo to implement a distributed test system. The issue I had was some times the main loop EV::run can't exit when all test done because some watchers are still active.  As watchers can be created on the fly, and some of them are created by other modules, so is there any way to tell what are the active watchers and where there were created?

     And thanks for the great work.

Thanks.
_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
Eric Fowler | 5 Apr 21:25 2016

Problem compiling lib_ev on windows

I am porting some Linux code containing libev to windows, and have run into a mysterious compilation issue.

The problem is manifested by a syntax error (repeated hundreds of times) in ev_vars.h:

#define VARx(type,name) VAR(name, type name)

VARx(ev_tstamp, now_floor)  // <<<<<< THIS CHOKES: "Error: expected a ')' "

VAR is defined in ev.c thusly:

struct ev_loop
  {
    ev_tstamp ev_rt_now;
    #define ev_rt_now ((loop)->ev_rt_now)
    #define VAR(name,decl) decl;
      #include "ev_vars.h"
    #undef VAR
  };

The problem seems to be that VAR is of the form SYMBOL(arg1, arg2 arg1). That space between the parameters
(arg2 arg1) confuses MSVC.

It looks like another Microsoft / g++ compiler snag, but I would expect the library creators to have caught
it by now, so something else must be wrong.
Working around this is certainly possible, but others who compile on Windows must have seen it, and I want to
know if I have committed a more fundamental and grievous error in my handling of libev.

Is this error familiar to anyone?

Thanks

Wabbit

________________________________
The information in this email, and any attachments, may contain confidential information and is intended
solely for the attention and use of the named addressee(s). It must not be disclosed to any person(s)
without authorization. If you are not the intended recipient, or a person responsible for delivering it
to the intended recipient, you are not authorized to, and must not, disclose, copy, distribute, or retain
this message or any part of it. If you have received this communication in error, please notify me immediately.

_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
prova1 | 5 Mar 01:25 2016

An up to date comparative Benchmark?

Hello everyone.

Has any benchmark been done recently? Everything I find is old and I 
would like to compare libev, libevent, libuv and the like.

Greetings! :)

_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
Arūnas Česonis | 28 Feb 17:22 2016
Picon

libev-4.22 C++ does not build without EV_SIGNAL_ENABLE

diff --git a/ev++.h b/ev++.h
index 4f0a36a..d1c84c8 100644
--- a/ev++.h
+++ b/ev++.h
 <at>  <at>  -337,10 +337,12  <at>  <at>  namespace ev {
       ev_feed_fd_event (EV_AX_ fd, revents);
     }

+#if EV_SIGNAL_ENABLE
     void feed_signal_event (int signum) throw ()
     {
       ev_feed_signal_event (EV_AX_ signum);
     }
+#endif

 #if EV_MULTIPLICITY
     struct ev_loop* EV_AX;

_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
adream | 28 Feb 07:42 2016
Picon

why parents and child has to recreate the epoll set after fork

Hi,
The  EVBACKEND_EPOLL part of  libev manual  said:
           The biggest issue is fork races, however - if
            a program forks then *both* parent and child process have to
            recreate the epoll set, which can take considerable time (one
            syscall per file descriptor) and is of course hard to detect.

I want to know why?

After did some google, this site said, if the child close fds, it will lead the fds clear form the epoll set in the parents.
https://lkml.org/lkml/2007/10/27/25

But my example code show that closing fds in child wouldn't clear the parents epoll set.

So I want to know why the parents and child should has to recreate the epoll set after fork.
Thank you.

this is my example code:

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<errno.h>
#include<netdb.h>
#include<fcntl.h>
#include<string.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<sys/un.h>
#include<netinet/in.h>
#include<netinet/in.h>
#include<netinet/tcp.h>
#include<arpa/inet.h>
#include<sys/epoll.h>


int StartTCPListener(const char* ip, const char* port)
{
    int server_sockfd;
    socklen_t server_len;
    struct sockaddr_in server_address;
    int flag;
    int reuse = 1;

    server_sockfd = socket(AF_INET,SOCK_STREAM,0);
    if(server_sockfd==-1) return -1;
    setsockopt(server_sockfd,SOL_SOCKET,SO_REUSEADDR,&reuse,sizeof(reuse));
    server_address.sin_family = AF_INET;
    server_address.sin_addr.s_addr = inet_addr(ip);
    server_address.sin_port = htons(atoi(port));
    server_len = sizeof(server_address);
    if( bind(server_sockfd,(struct sockaddr*)&server_address,server_len) ) return -1;
    if( listen(server_sockfd,SOMAXCONN) ) return -1;
    flag = fcntl(server_sockfd,F_GETFL);
    fcntl(server_sockfd,F_SETFL,flag|O_NONBLOCK);
    fcntl(server_sockfd, F_SETFD, FD_CLOEXEC);
    return server_sockfd;
}

int AcceptTCP(int server_fd)
{
    int client_fd;
    socklen_t client_len;
    struct sockaddr_in client_address;
    client_len = sizeof(client_address);
    int flag;

    client_fd = accept(server_fd,(struct sockaddr *)&client_address,&client_len);
    if(client_fd>0)
    {
        flag = fcntl(client_fd,F_GETFL);
        fcntl(client_fd,F_SETFL,flag|O_NONBLOCK|O_DSYNC);
        fcntl(client_fd, F_SETFD, FD_CLOEXEC);     
    }
    return client_fd;
}

static int AddToEpollSet (int efd, int fd, int events)
{
    struct epoll_event e;
    memset(&e, 0, sizeof(e));
    e.events = events;
    e.data.fd = fd;
    if (epoll_ctl(efd, EPOLL_CTL_ADD, fd, &e) == -1)
    {
        int err = errno;
        fprintf(stderr, "epoll_ctl(ADD) failed : %s\n", strerror(errno));
        return -1;
    }
    return 0;
}

int main(const int argc,const char* argv[])
{
    int cpid;
    int efd;
    int sfd = StartTCPListener(argv[1],argv[2]);
    struct epoll_event listener_evetn;
    int n;
    int cfd;
    const char *msg="Hello world!\n";

    if(sfd<0)
    {
        fprintf(stderr,"set socket listening error : %s\n",strerror(errno));
        return -1;
    }
    efd=epoll_create(8);
    if(efd<0)
    {
        fprintf(stderr,"epoll_create error : %s\n",strerror(errno));
        return -1;
    }
    if(AddToEpollSet(efd,sfd,EPOLLIN)<0)
    {
        fprintf(stderr,"add socket to epoll set error : %s\n",strerror(errno));
        return -1;
    }

    cpid=fork();
    if(cpid<0)
    {
        fprintf(stderr,"fork error : %s\n",strerror(errno));
        return -1;
    }
    if(cpid==0)
    {
        printf("child progress %d\n",getpid());
        close(sfd);
        exit(0);
    }
    waitpid(cpid,NULL,0);
    printf("%d fork %d\n",getpid(),cpid);
    n=epoll_wait(efd,&listener_evetn,1,-1);
    if(n>0)
    {
        if(listener_evetn.events & EPOLLIN)
        {
            cfd=AcceptTCP(listener_evetn.data.fd);
            if(cfd>0)
            {
                write(cfd,msg,strlen(msg));
                close(cfd);
            }
        }
    }
    close(sfd);
    close(efd);
}



_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
Ponomarenko Andrey | 26 Feb 13:27 2016
Picon

ABI report

Hello,

I've prepared ABI changes/backward binary compatibility report for the recent versions of the libev: http://abi-laboratory.pro/tracker/timeline/libev/

Hope the report will help Linux maintainers to be aware of future and past ABI changes, added/removed
binary symbols and SONAME bumps. Source code of the project is here: https://github.com/lvc/abi-tracker

Please let me know if there are some false positives/negatives in the report.

Thank you.

_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
adream | 24 Feb 14:22 2016
Picon

question on ev_loop_fork

hi
    I thought, if I didn't call the ev_loop_fork in the child, then the watcher in child wouldn't be triggered.
    This is my code, I build the ev_loop with EVBACKEND_EPOLL and EVFLAG_NOENV flags, so there is no EVFLAG_FORKCHECK flag, then I comment the ev_loop_fork call in the child. if everything goes well, I thought the child will not trigger the timeout callback function. but actually, the output is something like this:
4980 fork 4981
time out at 4980
time out at 4981
     it means that the watchers also has been triggered in the child.




#include<ev.h>
#include<stdio.h>
#include<unistd.h>

void timeout_cb(EV_P_ ev_timer *w,int revents)
{
    printf("time out at %d\n", getpid());
    ev_break(EV_A_ EVBREAK_ONE);
}

int main()
{
    int ret;
    ev_timer timeout_watcher;

    struct ev_loop *loop = ev_default_loop(EVBACKEND_EPOLL | EVFLAG_NOENV);

    ev_timer_init(&timeout_watcher,timeout_cb,5.5,0.);
    ev_timer_start(loop,&timeout_watcher);
    ret = fork();
    if(ret>0) printf("%d fork %d\n",getpid(),ret);
    else if(ret==0)
    {
        //ev_loop_fork(EV_DEFAULT);
    }
    else return -1;
    ev_run(loop,0);
    return 0;
}
_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
Nick Zavaritsky | 24 Feb 17:35 2016
Picon

Error handling / ev_set_syserr_cb

Hi Mark,

Libev provides ev_set_syserr_cb() to customise error handling.

I wonder, if longjump-ing from a error handler is supported.

Consider a longjump removing all libev frames from the stack and landing at some location that was set up earlier.
Are we going to get any leaks inside libev? Is that contractual?

Regards,
Nick
_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
Gabriel Lambert | 17 Feb 09:26 2016
Picon

libev directory detection

i can't seem to get libev to detect changes in a directory, whether that be files being added or modified
_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
Chris Galas | 15 Feb 23:31 2016

ev_io write/read timing issue

I've come upon a strange issue.

I'm reading data from a USB serial port on Linux, using separate reader and writer ev_io watchers. Commands
(bytes) are written to the file descriptor in a write call back and bytes are read back on a read call back.
This works for about 80 write/read exchanges until the read call back function is no longer called and the
program blocks, no longer calling the read call back function.

I suspect it's some timing issue but I'm not sure what at time this. I can put in 50ms usleeps between read and
writes, but that only delays the block. Are there timing issues when using a pair of ev_io read/write
watchers? 

I've included a simple example with some output here: https://github.com/oldmancoyote/some_test_code



_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev
Alex Efros | 14 Feb 17:15 2016
Gravatar

unreliable timer with RUN_ONCE since 4.10

Hi!

The example is in Perl, but I suppose issue is with libev, not EV.
EV-4.03 doesn't have this issue, EV-4.10 to 4.22 have this issue.
It may be related to improvement for low resolution clock mentioned in
this list for 4.10 (May 2011).

Problem is: timer for < 1sec doesn't invoked by first RUN_ONCE.

$ cat ev-4.10_bug 
#!/usr/bin/perl
use EV;
print "EV-$EV::VERSION\n";
my $w = EV::timer $ARGV[0], 0, sub { print "timer\n" };
print "ONE\n";
EV::run(EV::RUN_ONCE);
print "TWO\n";
EV::run(EV::RUN_ONCE);

$ ./ev-4.10_bug 0.1
EV-4.03
ONE
timer
TWO

$ ./ev-4.10_bug 0.1
EV-4.10
ONE
TWO
timer

$ ./ev-4.10_bug 1
EV-4.10
ONE
timer
TWO

With 0.9 sec versions 4.10-4.22 works unreliably: sometimes timer invoked
by first RUN_ONCE, sometimes not - so I've used 0.1 and 1 sec in this
example.

--

-- 
			WBR, Alex.

_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

Gmane