linux - Problem handling file I/O with libevent2 -


I have worked with libevent2 for a while, but usually I use it for network I / O (use of sockets From). Now I need to read many different files, so I want to use it I have created this code:

  int file = open (file name, O_RDONLY); Structure event * ev_file_read = event_new (ev_base, file, EV_READ | EV_PERSIST, read_file, NULL); If (event_add (ev_file_read, NULL)) error ("add file event");   

Unfortunately this does not work. I get this message when I try to add an event:

[Warning] Apollo ADD on FD7 (1 ) Failed old events were 0; Reading change was 1 (added); Writing change was 0 (none): Operation is not allowed to add file event: Operation is not allowed

The file exists and has the right to read / write

Anyone have any idea how file can handle IO using libevent? I also thought about buffer incidents, but the only function in the API is bufferevent_socket_new () which does not apply here.

Thank you in advance.

I need libevent to read many files about preferences The problem was not in the appolor, In which libevent was. Epoll does not support regular Unix files

To resolve this, I have forced Libevent to not use Ebol:

  struct event_config * cfg = Event_config_new (); Event_config_avoid_method (cfg, "appol"); Ev_base = event_base_new_with_config (cgg); Event_config_free (cfg);   

The next method was the selection of the priority list, which fully supported files as I wanted.

Thanks for the reply.

Comments