ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.325 by root, Sun Jan 24 12:31:55 2010 UTC vs.
Revision 1.326 by root, Tue Jan 26 04:19:37 2010 UTC

1/* 1/*
2 * libev event processing core, watcher management 2 * libev event processing core, watcher management
3 * 3 *
4 * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
163 163
164#include <assert.h> 164#include <assert.h>
165#include <errno.h> 165#include <errno.h>
166#include <sys/types.h> 166#include <sys/types.h>
167#include <time.h> 167#include <time.h>
168#include <limits.h>
168 169
169#include <signal.h> 170#include <signal.h>
170 171
171#ifdef EV_H 172#ifdef EV_H
172# include EV_H 173# include EV_H
2859#define MIN_STAT_INTERVAL 0.1074891 2860#define MIN_STAT_INTERVAL 0.1074891
2860 2861
2861static void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents); 2862static void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents);
2862 2863
2863#if EV_USE_INOTIFY 2864#if EV_USE_INOTIFY
2864# define EV_INOTIFY_BUFSIZE 8192 2865
2866/* the * 2 is to allow for alignment padding, which for some reason is >> 8 */
2867# define EV_INOTIFY_BUFSIZE (sizeof (struct inotify_event) * 2 + NAME_MAX)
2865 2868
2866static void noinline 2869static void noinline
2867infy_add (EV_P_ ev_stat *w) 2870infy_add (EV_P_ ev_stat *w)
2868{ 2871{
2869 w->wd = inotify_add_watch (fs_fd, w->path, IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY | IN_DONT_FOLLOW | IN_MASK_ADD); 2872 w->wd = inotify_add_watch (fs_fd, w->path, IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY | IN_DONT_FOLLOW | IN_MASK_ADD);
2978 2981
2979static void 2982static void
2980infy_cb (EV_P_ ev_io *w, int revents) 2983infy_cb (EV_P_ ev_io *w, int revents)
2981{ 2984{
2982 char buf [EV_INOTIFY_BUFSIZE]; 2985 char buf [EV_INOTIFY_BUFSIZE];
2983 struct inotify_event *ev = (struct inotify_event *)buf;
2984 int ofs; 2986 int ofs;
2985 int len = read (fs_fd, buf, sizeof (buf)); 2987 int len = read (fs_fd, buf, sizeof (buf));
2986 2988
2987 for (ofs = 0; ofs < len; ofs += sizeof (struct inotify_event) + ev->len) 2989 for (ofs = 0; ofs < len; )
2990 {
2991 struct inotify_event *ev = (struct inotify_event *)(buf + ofs);
2988 infy_wd (EV_A_ ev->wd, ev->wd, ev); 2992 infy_wd (EV_A_ ev->wd, ev->wd, ev);
2993 ofs += sizeof (struct inotify_event) + ev->len;
2994 }
2989} 2995}
2990 2996
2991inline_size void 2997inline_size void
2992check_2625 (EV_P) 2998check_2625 (EV_P)
2993{ 2999{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines