Subversion Repositories public

Rev

Rev 73 | Rev 79 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 73 Rev 75
Line 106... Line 106...
106
}
106
}
107
107
108
108
109
109
110
110
111
/// Attempts to load all user incron tables.
111
/// Attempts to load all (user and system) incron tables.
112
/**
112
/**
113
 * Loaded tables are registered for processing events.
113
 * Loaded tables are registered for processing events.
114
 *
114
 *
115
 * \param[in] pEd inotify event dispatcher
115
 * \param[in] pEd inotify event dispatcher
116
 *
116
 *
Line 189... Line 189...
189
  }
189
  }
190
 
190
 
191
  closedir(d);
191
  closedir(d);
192
}
192
}
193
193
-
 
194
/// Deallocates all memory used by incron tables and unregisters them from the dispatcher.
-
 
195
/**
-
 
196
 * \param[in] pEd event dispatcher
-
 
197
 */
-
 
198
void free_tables(EventDispatcher* pEd)
-
 
199
{
-
 
200
  pEd->Clear();
-
 
201
 
-
 
202
  SUT_MAP::iterator it = g_ut.begin();
-
 
203
  while (it != g_ut.end()) {
-
 
204
    UserTable* pUt = (*it).second;
-
 
205
    delete pUt;
-
 
206
    it++;
-
 
207
  }
-
 
208
 
-
 
209
  g_ut.clear();
-
 
210
}
-
 
211
194
/// Prepares a 'dead/done child' notification pipe.
212
/// Prepares a 'dead/done child' notification pipe.
195
/**
213
/**
196
 * This function returns no value at all and on error it
214
 * This function returns no value at all and on error it
197
 * throws an exception.
215
 * throws an exception.
198
 */
216
 */
Line 233... Line 251...
233
 * \param[in] s checked string
251
 * \param[in] s checked string
234
 * \param[in] shortCmd short form of command
252
 * \param[in] shortCmd short form of command
235
 * \param[in] longCmd long form of command
253
 * \param[in] longCmd long form of command
236
 * \return true = string accepted, false = otherwise
254
 * \return true = string accepted, false = otherwise
237
 */  
255
 */  
-
 
256
 /*
238
bool check_parameter(const char* s, const char* shortCmd, const char* longCmd)
257
bool check_parameter(const char* s, const char* shortCmd, const char* longCmd)
239
{
258
{
240
  return strcmp(s, shortCmd)  == 0
259
  return strcmp(s, shortCmd)  == 0
241
      || strcmp(s, longCmd)   == 0;
260
      || strcmp(s, longCmd)   == 0;
242
}
261
}
-
 
262
*/
243
263
244
/// Initializes a poll array.
264
/// Initializes a poll array.
245
/**
265
/**
246
 * \param[out] pfd poll structure array
266
 * \param[out] pfd poll structure array
247
 * \param[in] pipefd pipe file descriptor
267
 * \param[in] pipefd pipe file descriptor
Line 312... Line 332...
312
  AppInstance app(lckfile, lckdir);
332
  AppInstance app(lckfile, lckdir);
313
 
333
 
314
  if (AppArgs::ExistsOption("kill")) {
334
  if (AppArgs::ExistsOption("kill")) {
315
    fprintf(stderr, "attempting to terminate a running instance of incrond...\n");
335
    fprintf(stderr, "attempting to terminate a running instance of incrond...\n");
316
    if (app.Terminate()) {
336
    if (app.Terminate()) {
317
      fprintf(stderr, "instance(s) notified, going down\n");
337
      fprintf(stderr, "the instance notified, going down\n");
318
      return 0;
338
      return 0;
319
    }
339
    }
320
    else {
340
    else {
321
      fprintf(stderr, "error - incrond probably not running\n");
341
      fprintf(stderr, "error - incrond probably not running\n");
322
      return 1;
342
      return 1;
Line 384... Line 404...
384
   
404
   
385
    Inotify in;
405
    Inotify in;
386
    in.SetNonBlock(true);
406
    in.SetNonBlock(true);
387
    in.SetCloseOnExec(true);
407
    in.SetCloseOnExec(true);
388
   
408
   
389
    uint32_t wm = IN_CLOSE_WRITE | IN_DELETE | IN_MOVE | IN_DELETE_SELF | IN_UNMOUNT;
409
    uint32_t wm = IN_CREATE | IN_CLOSE_WRITE | IN_DELETE | IN_MOVE | IN_DELETE_SELF | IN_UNMOUNT;
390
    InotifyWatch stw(sysBase, wm);
410
    InotifyWatch stw(sysBase, wm);
391
    in.Add(stw);
411
    in.Add(stw);
392
    InotifyWatch utw(userBase, wm);
412
    InotifyWatch utw(userBase, wm);
393
    in.Add(utw);
413
    in.Add(utw);
394
   
414
   
Line 401... Line 421...
401
      syslog(LOG_CRIT, "%s: (%i) %s", e.GetMessage().c_str(), err, strerror(err));
421
      syslog(LOG_CRIT, "%s: (%i) %s", e.GetMessage().c_str(), err, strerror(err));
402
      ret = 1;
422
      ret = 1;
403
      goto error;
423
      goto error;
404
    }
424
    }
405
   
425
   
-
 
426
    ed.Rebuild(); // not too efficient, but simple 
-
 
427
   
406
    signal(SIGTERM, on_signal);
428
    signal(SIGTERM, on_signal);
407
    signal(SIGINT, on_signal);
429
    signal(SIGINT, on_signal);
408
    signal(SIGCHLD, on_signal);
430
    signal(SIGCHLD, on_signal);
409
   
431
   
410
    syslog(LOG_NOTICE, "ready to process filesystem events");
432
    syslog(LOG_NOTICE, "ready to process filesystem events");
Line 422... Line 444...
422
          throw InotifyException("polling failed", errno, NULL);
444
          throw InotifyException("polling failed", errno, NULL);
423
      }
445
      }
424
     
446
     
425
    }
447
    }
426
   
448
   
-
 
449
    free_tables(&ed);
-
 
450
   
427
    if (g_cldPipe[0] != -1)
451
    if (g_cldPipe[0] != -1)
428
      close(g_cldPipe[0]);
452
      close(g_cldPipe[0]);
429
    if (g_cldPipe[1] != -1)
453
    if (g_cldPipe[1] != -1)
430
      close(g_cldPipe[1]);
454
      close(g_cldPipe[1]);
431
  } catch (InotifyException e) {
455
  } catch (InotifyException e) {