NeoMutt  2023-05-17-56-ga67199
Teaching an old dog new tricks
DOXYGEN
monitor.c File Reference

Monitor files for changes. More...

#include "config.h"
#include <errno.h>
#include <limits.h>
#include <poll.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <sys/inotify.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "monitor.h"
#include "index/lib.h"
#include <fcntl.h>
+ Include dependency graph for monitor.c:

Go to the source code of this file.

Data Structures

struct  Monitor
 A watch on a file. More...
 
struct  MonitorInfo
 Information about a monitored file. More...
 

Macros

#define INOTIFY_MASK_DIR   (IN_MOVED_TO | IN_ATTRIB | IN_CLOSE_WRITE | IN_ISDIR)
 
#define INOTIFY_MASK_FILE   IN_CLOSE_WRITE
 
#define EVENT_BUFLEN   MAX(4096, sizeof(struct inotify_event) + NAME_MAX + 1)
 

Enumerations

enum  ResolveResult {
  RESOLVE_RES_FAIL_NOMAILBOX = -3 , RESOLVE_RES_FAIL_NOTYPE = -2 , RESOLVE_RES_FAIL_STAT = -1 , RESOLVE_RES_OK_NOTEXISTING = 0 ,
  RESOLVE_RES_OK_EXISTING = 1
}
 Results for the Monitor functions. More...
 

Functions

static void mutt_poll_fd_add (int fd, short events)
 Add a file to the watch list. More...
 
static int mutt_poll_fd_remove (int fd)
 Remove a file from the watch list. More...
 
static int monitor_init (void)
 Set up file monitoring. More...
 
static void monitor_check_free (void)
 Close down file monitoring. More...
 
static struct Monitormonitor_new (struct MonitorInfo *info, int descriptor)
 Create a new file monitor. More...
 
static void monitor_info_init (struct MonitorInfo *info)
 Set up a file monitor. More...
 
static void monitor_info_free (struct MonitorInfo *info)
 Shutdown a file monitor. More...
 
static void monitor_delete (struct Monitor *monitor)
 Free a file monitor. More...
 
static int monitor_handle_ignore (int desc)
 Listen for when a backup file is closed. More...
 
static enum ResolveResult monitor_resolve (struct MonitorInfo *info, struct Mailbox *m)
 Get the monitor for a mailbox. More...
 
int mutt_monitor_poll (void)
 Check for filesystem changes. More...
 
int mutt_monitor_add (struct Mailbox *m)
 Add a watch for a mailbox. More...
 
int mutt_monitor_remove (struct Mailbox *m)
 Remove a watch for a mailbox. More...
 

Variables

bool MonitorFilesChanged = false
 Set to true when a monitored file has changed. More...
 
bool MonitorContextChanged = false
 Set to true when the current mailbox has changed. More...
 
static int INotifyFd = -1
 Inotify file descriptor. More...
 
static struct MonitorMonitor = NULL
 Linked list of monitored Mailboxes. More...
 
static size_t PollFdsCount = 0
 Number of used entries in the PollFds array. More...
 
static size_t PollFdsLen = 0
 Size of PollFds array. More...
 
static struct pollfd * PollFds = NULL
 Array of monitored file descriptors. More...
 
static int MonitorContextDescriptor = -1
 Monitor file descriptor of the current mailbox. More...
 

Detailed Description

Monitor files for changes.

Authors
  • Gero Treuer
  • R Primus

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file monitor.c.

Macro Definition Documentation

◆ INOTIFY_MASK_DIR

#define INOTIFY_MASK_DIR   (IN_MOVED_TO | IN_ATTRIB | IN_CLOSE_WRITE | IN_ISDIR)

Definition at line 67 of file monitor.c.

◆ INOTIFY_MASK_FILE

#define INOTIFY_MASK_FILE   IN_CLOSE_WRITE

Definition at line 68 of file monitor.c.

◆ EVENT_BUFLEN

#define EVENT_BUFLEN   MAX(4096, sizeof(struct inotify_event) + NAME_MAX + 1)

Definition at line 70 of file monitor.c.

Enumeration Type Documentation

◆ ResolveResult

Results for the Monitor functions.

Enumerator
RESOLVE_RES_FAIL_NOMAILBOX 

No Mailbox to work on.

RESOLVE_RES_FAIL_NOTYPE 

Can't identify Mailbox type.

RESOLVE_RES_FAIL_STAT 

Can't stat() the Mailbox file.

RESOLVE_RES_OK_NOTEXISTING 

File exists, no monitor is attached.

RESOLVE_RES_OK_EXISTING 

File exists, monitor is already attached.

Definition at line 75 of file monitor.c.

76{
82};
@ RESOLVE_RES_FAIL_NOTYPE
Can't identify Mailbox type.
Definition: monitor.c:78
@ RESOLVE_RES_FAIL_STAT
Can't stat() the Mailbox file.
Definition: monitor.c:79
@ RESOLVE_RES_OK_NOTEXISTING
File exists, no monitor is attached.
Definition: monitor.c:80
@ RESOLVE_RES_FAIL_NOMAILBOX
No Mailbox to work on.
Definition: monitor.c:77
@ RESOLVE_RES_OK_EXISTING
File exists, monitor is already attached.
Definition: monitor.c:81

Function Documentation

◆ mutt_poll_fd_add()

static void mutt_poll_fd_add ( int  fd,
short  events 
)
static

Add a file to the watch list.

Parameters
fdFile to watch
eventsEvents to listen for, e.g. POLLIN

Definition at line 116 of file monitor.c.

117{
118 int i = 0;
119 for (; (i < PollFdsCount) && (PollFds[i].fd != fd); i++)
120 ; // do nothing
121
122 if (i == PollFdsCount)
123 {
125 {
126 PollFdsLen += 2;
127 mutt_mem_realloc(&PollFds, PollFdsLen * sizeof(struct pollfd));
128 }
129 PollFdsCount++;
130 PollFds[i].fd = fd;
131 PollFds[i].events = events;
132 }
133 else
134 {
135 PollFds[i].events |= events;
136 }
137}
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
static size_t PollFdsCount
Number of used entries in the PollFds array.
Definition: monitor.c:59
static size_t PollFdsLen
Size of PollFds array.
Definition: monitor.c:61
static struct pollfd * PollFds
Array of monitored file descriptors.
Definition: monitor.c:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_poll_fd_remove()

static int mutt_poll_fd_remove ( int  fd)
static

Remove a file from the watch list.

Parameters
fdFile to remove
Return values
0Success
-1Error

Definition at line 145 of file monitor.c.

146{
147 int i = 0;
148 for (; (i < PollFdsCount) && (PollFds[i].fd != fd); i++)
149 ; // do nothing
150
151 if (i == PollFdsCount)
152 return -1;
153 int d = PollFdsCount - i - 1;
154 if (d != 0)
155 memmove(&PollFds[i], &PollFds[i + 1], d * sizeof(struct pollfd));
156 PollFdsCount--;
157 return 0;
158}
+ Here is the caller graph for this function:

◆ monitor_init()

static int monitor_init ( void  )
static

Set up file monitoring.

Return values
0Success
-1Error

Definition at line 165 of file monitor.c.

166{
167 if (INotifyFd != -1)
168 return 0;
169
170#ifdef HAVE_INOTIFY_INIT1
171 INotifyFd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
172 if (INotifyFd == -1)
173 {
174 mutt_debug(LL_DEBUG2, "inotify_init1 failed, errno=%d %s\n", errno, strerror(errno));
175 return -1;
176 }
177#else
178 INotifyFd = inotify_init();
179 if (INotifyFd == -1)
180 {
181 mutt_debug(LL_DEBUG2, "monitor: inotify_init failed, errno=%d %s\n", errno,
182 strerror(errno));
183 return -1;
184 }
185 fcntl(INotifyFd, F_SETFL, O_NONBLOCK);
186 fcntl(INotifyFd, F_SETFD, FD_CLOEXEC);
187#endif
188 mutt_poll_fd_add(0, POLLIN);
190
191 return 0;
192}
#define mutt_debug(LEVEL,...)
Definition: logging2.h:87
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
static int INotifyFd
Inotify file descriptor.
Definition: monitor.c:55
static void mutt_poll_fd_add(int fd, short events)
Add a file to the watch list.
Definition: monitor.c:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ monitor_check_free()

static void monitor_check_free ( void  )
static

Close down file monitoring.

Definition at line 197 of file monitor.c.

198{
199 if (!Monitor && (INotifyFd != -1))
200 {
202 close(INotifyFd);
203 INotifyFd = -1;
204 MonitorFilesChanged = false;
205 }
206}
static int mutt_poll_fd_remove(int fd)
Remove a file from the watch list.
Definition: monitor.c:145
bool MonitorFilesChanged
Set to true when a monitored file has changed.
Definition: monitor.c:50
A watch on a file.
Definition: monitor.c:88
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ monitor_new()

static struct Monitor * monitor_new ( struct MonitorInfo info,
int  descriptor 
)
static

Create a new file monitor.

Parameters
infoDetails of file to monitor
descriptorWatch descriptor
Return values
ptrNewly allocated Monitor

Definition at line 214 of file monitor.c.

215{
216 struct Monitor *monitor = mutt_mem_calloc(1, sizeof(struct Monitor));
217 monitor->type = info->type;
218 monitor->st_dev = info->st_dev;
219 monitor->st_ino = info->st_ino;
220 monitor->desc = descriptor;
221 monitor->next = Monitor;
222 if (info->type == MUTT_MH)
223 monitor->mh_backup_path = mutt_str_dup(info->path);
224
225 Monitor = monitor;
226
227 return monitor;
228}
@ MUTT_MH
'MH' Mailbox type
Definition: mailbox.h:47
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
static struct Monitor * Monitor
Linked list of monitored Mailboxes.
Definition: monitor.c:57
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:251
dev_t st_dev
Definition: monitor.c:105
enum MailboxType type
Definition: monitor.c:102
ino_t st_ino
Definition: monitor.c:106
const char * path
Definition: monitor.c:104
struct Monitor * next
Linked list.
Definition: monitor.c:89
ino_t st_ino
Definition: monitor.c:92
dev_t st_dev
Definition: monitor.c:91
int desc
Definition: monitor.c:94
enum MailboxType type
Definition: monitor.c:93
char * mh_backup_path
Definition: monitor.c:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ monitor_info_init()

static void monitor_info_init ( struct MonitorInfo info)
static

Set up a file monitor.

Parameters
infoMonitor to initialise

Definition at line 234 of file monitor.c.

235{
236 memset(info, 0, sizeof(*info));
237}
+ Here is the caller graph for this function:

◆ monitor_info_free()

static void monitor_info_free ( struct MonitorInfo info)
static

Shutdown a file monitor.

Parameters
infoMonitor to shut down

Definition at line 243 of file monitor.c.

244{
245 buf_dealloc(&info->path_buf);
246}
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:383
struct Buffer path_buf
access via path only (maybe not initialized)
Definition: monitor.c:108
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ monitor_delete()

static void monitor_delete ( struct Monitor monitor)
static

Free a file monitor.

Parameters
monitorMonitor to free

Definition at line 252 of file monitor.c.

253{
254 if (!monitor)
255 return;
256
257 struct Monitor **ptr = &Monitor;
258
259 while (true)
260 {
261 if (!*ptr)
262 return;
263 if (*ptr == monitor)
264 break;
265 ptr = &(*ptr)->next;
266 }
267
268 FREE(&monitor->mh_backup_path);
269 monitor = monitor->next;
270 FREE(ptr);
271 *ptr = monitor;
272}
#define FREE(x)
Definition: memory.h:43
+ Here is the caller graph for this function:

◆ monitor_handle_ignore()

static int monitor_handle_ignore ( int  desc)
static

Listen for when a backup file is closed.

Parameters
descWatch descriptor
Return values
>=0New descriptor
-1Error

Definition at line 280 of file monitor.c.

281{
282 int new_desc = -1;
283 struct Monitor *iter = Monitor;
284 struct stat st = { 0 };
285
286 while (iter && (iter->desc != desc))
287 iter = iter->next;
288
289 if (iter)
290 {
291 if ((iter->type == MUTT_MH) && (stat(iter->mh_backup_path, &st) == 0))
292 {
293 new_desc = inotify_add_watch(INotifyFd, iter->mh_backup_path, INOTIFY_MASK_FILE);
294 if (new_desc == -1)
295 {
296 mutt_debug(LL_DEBUG2, "inotify_add_watch failed for '%s', errno=%d %s\n",
297 iter->mh_backup_path, errno, strerror(errno));
298 }
299 else
300 {
301 mutt_debug(LL_DEBUG3, "inotify_add_watch descriptor=%d for '%s'\n",
302 desc, iter->mh_backup_path);
303 iter->st_dev = st.st_dev;
304 iter->st_ino = st.st_ino;
305 iter->desc = new_desc;
306 }
307 }
308 else
309 {
310 mutt_debug(LL_DEBUG3, "cleanup watch (implicitly removed) - descriptor=%d\n", desc);
311 }
312
313 if (MonitorContextDescriptor == desc)
314 MonitorContextDescriptor = new_desc;
315
316 if (new_desc == -1)
317 {
318 monitor_delete(iter);
320 }
321 }
322
323 return new_desc;
324}
@ LL_DEBUG3
Log at debug level 3.
Definition: logging2.h:45
static void monitor_delete(struct Monitor *monitor)
Free a file monitor.
Definition: monitor.c:252
static int MonitorContextDescriptor
Monitor file descriptor of the current mailbox.
Definition: monitor.c:65
static void monitor_check_free(void)
Close down file monitoring.
Definition: monitor.c:197
#define INOTIFY_MASK_FILE
Definition: monitor.c:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ monitor_resolve()

static enum ResolveResult monitor_resolve ( struct MonitorInfo info,
struct Mailbox m 
)
static

Get the monitor for a mailbox.

Parameters
[out]infoDetails of the mailbox's monitor
[in]mMailbox
Return values
>=0mailbox is valid and locally accessible: 0: no monitor / 1: preexisting monitor
-3no mailbox (MonitorInfo: no fields set)
-2type not set
-1stat() failed (see errno; MonitorInfo fields: type, is_dir, path)

If m is NULL, try to get the current mailbox from the Index.

Definition at line 338 of file monitor.c.

339{
340 char *fmt = NULL;
341 struct stat st = { 0 };
342
343 struct Mailbox *m_cur = get_current_mailbox();
344 if (m)
345 {
346 info->type = m->type;
347 info->path = m->realpath;
348 }
349 else if (m_cur)
350 {
351 info->type = m_cur->type;
352 info->path = m_cur->realpath;
353 }
354 else
355 {
357 }
358
359 if (info->type == MUTT_UNKNOWN)
360 {
362 }
363 else if (info->type == MUTT_MAILDIR)
364 {
365 info->is_dir = true;
366 fmt = "%s/new";
367 }
368 else
369 {
370 info->is_dir = false;
371 if (info->type == MUTT_MH)
372 fmt = "%s/.mh_sequences";
373 }
374 if (fmt)
375 {
376 buf_printf(&info->path_buf, fmt, info->path);
377 info->path = buf_string(&info->path_buf);
378 }
379 if (stat(info->path, &st) != 0)
381
382 struct Monitor *iter = Monitor;
383 while (iter && ((iter->st_ino != st.st_ino) || (iter->st_dev != st.st_dev)))
384 iter = iter->next;
385
386 info->st_dev = st.st_dev;
387 info->st_ino = st.st_ino;
388 info->monitor = iter;
389
391}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:173
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:90
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
Definition: index.c:662
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition: mailbox.h:44
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition: mailbox.h:48
A mailbox.
Definition: mailbox.h:79
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:81
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
struct Monitor * monitor
Definition: monitor.c:107
bool is_dir
Definition: monitor.c:103
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_monitor_poll()

int mutt_monitor_poll ( void  )

Check for filesystem changes.

Return values
-3unknown/unexpected events: poll timeout / fds not handled by us
-2monitor detected changes, no STDIN input
-1error (see errno)
0(1) input ready from STDIN, or (2) monitoring inactive -> no poll()

Wait for I/O ready file descriptors or signals.

MonitorFilesChanged also reflects changes to monitored files.

Only STDIN and INotify file handles currently expected/supported. More would ask for common infrastructure (sockets?).

Definition at line 407 of file monitor.c.

408{
409 int rc = 0;
410 char buf[EVENT_BUFLEN] __attribute__((aligned(__alignof__(struct inotify_event))));
411
412 MonitorFilesChanged = false;
413
414 if (INotifyFd != -1)
415 {
416 int fds = poll(PollFds, PollFdsCount, MuttGetchTimeout);
417
418 if (fds == -1)
419 {
420 rc = -1;
421 if (errno != EINTR)
422 {
423 mutt_debug(LL_DEBUG2, "poll() failed, errno=%d %s\n", errno, strerror(errno));
424 }
425 }
426 else
427 {
428 bool input_ready = false;
429 for (int i = 0; fds && (i < PollFdsCount); i++)
430 {
431 if (PollFds[i].revents)
432 {
433 fds--;
434 if (PollFds[i].fd == 0)
435 {
436 input_ready = true;
437 }
438 else if (PollFds[i].fd == INotifyFd)
439 {
440 MonitorFilesChanged = true;
441 mutt_debug(LL_DEBUG3, "file change(s) detected\n");
442 char *ptr = buf;
443 const struct inotify_event *event = NULL;
444
445 while (true)
446 {
447 int len = read(INotifyFd, buf, sizeof(buf));
448 if (len == -1)
449 {
450 if (errno != EAGAIN)
451 {
452 mutt_debug(LL_DEBUG2, "read inotify events failed, errno=%d %s\n",
453 errno, strerror(errno));
454 }
455 break;
456 }
457
458 while (ptr < (buf + len))
459 {
460 event = (const struct inotify_event *) ptr;
461 mutt_debug(LL_DEBUG3, "+ detail: descriptor=%d mask=0x%x\n",
462 event->wd, event->mask);
463 if (event->mask & IN_IGNORED)
464 monitor_handle_ignore(event->wd);
465 else if (event->wd == MonitorContextDescriptor)
467 ptr += sizeof(struct inotify_event) + event->len;
468 }
469 }
470 }
471 }
472 }
473 if (!input_ready)
474 rc = MonitorFilesChanged ? -2 : -3;
475 }
476 }
477
478 return rc;
479}
int MuttGetchTimeout
Timeout for getting a character from the user.
Definition: curs_lib.c:125
static int monitor_handle_ignore(int desc)
Listen for when a backup file is closed.
Definition: monitor.c:280
bool MonitorContextChanged
Set to true when the current mailbox has changed.
Definition: monitor.c:52
#define EVENT_BUFLEN
Definition: monitor.c:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_monitor_add()

int mutt_monitor_add ( struct Mailbox m)

Add a watch for a mailbox.

Parameters
mMailbox to watch
Return values
0success: new or already existing monitor
-1failed: no mailbox, inaccessible file, create monitor/watcher failed

If m is NULL, try to get the current mailbox from the Index.

Definition at line 489 of file monitor.c.

490{
491 struct MonitorInfo info;
492 monitor_info_init(&info);
493
494 int rc = 0;
495 enum ResolveResult desc = monitor_resolve(&info, m);
496 if (desc != RESOLVE_RES_OK_NOTEXISTING)
497 {
498 if (!m && (desc == RESOLVE_RES_OK_EXISTING))
499 MonitorContextDescriptor = info.monitor->desc;
500 rc = (desc == RESOLVE_RES_OK_EXISTING) ? 0 : -1;
501 goto cleanup;
502 }
503
504 uint32_t mask = info.is_dir ? INOTIFY_MASK_DIR : INOTIFY_MASK_FILE;
505 if (((INotifyFd == -1) && (monitor_init() == -1)) ||
506 ((desc = inotify_add_watch(INotifyFd, info.path, mask)) == -1))
507 {
508 mutt_debug(LL_DEBUG2, "inotify_add_watch failed for '%s', errno=%d %s\n",
509 info.path, errno, strerror(errno));
510 rc = -1;
511 goto cleanup;
512 }
513
514 mutt_debug(LL_DEBUG3, "inotify_add_watch descriptor=%d for '%s'\n", desc, info.path);
515 if (!m)
517
518 monitor_new(&info, desc);
519
520cleanup:
521 monitor_info_free(&info);
522 return rc;
523}
#define INOTIFY_MASK_DIR
Definition: monitor.c:67
static enum ResolveResult monitor_resolve(struct MonitorInfo *info, struct Mailbox *m)
Get the monitor for a mailbox.
Definition: monitor.c:338
static struct Monitor * monitor_new(struct MonitorInfo *info, int descriptor)
Create a new file monitor.
Definition: monitor.c:214
ResolveResult
Results for the Monitor functions.
Definition: monitor.c:76
static int monitor_init(void)
Set up file monitoring.
Definition: monitor.c:165
static void monitor_info_init(struct MonitorInfo *info)
Set up a file monitor.
Definition: monitor.c:234
static void monitor_info_free(struct MonitorInfo *info)
Shutdown a file monitor.
Definition: monitor.c:243
Information about a monitored file.
Definition: monitor.c:101
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_monitor_remove()

int mutt_monitor_remove ( struct Mailbox m)

Remove a watch for a mailbox.

Parameters
mMailbox
Return values
0monitor removed (not shared)
1monitor not removed (shared)
2no monitor

If m is NULL, try to get the current mailbox from the Index.

Definition at line 534 of file monitor.c.

535{
536 struct MonitorInfo info, info2;
537 int rc = 0;
538
539 monitor_info_init(&info);
540 monitor_info_init(&info2);
541
542 if (!m)
543 {
545 MonitorContextChanged = false;
546 }
547
549 {
550 rc = 2;
551 goto cleanup;
552 }
553
554 struct Mailbox *m_cur = get_current_mailbox();
555 if (m_cur)
556 {
557 if (m)
558 {
559 if ((monitor_resolve(&info2, NULL) == RESOLVE_RES_OK_EXISTING) &&
560 (info.st_ino == info2.st_ino) && (info.st_dev == info2.st_dev))
561 {
562 rc = 1;
563 goto cleanup;
564 }
565 }
566 else
567 {
568 if (mailbox_find(m_cur->realpath))
569 {
570 rc = 1;
571 goto cleanup;
572 }
573 }
574 }
575
576 inotify_rm_watch(info.monitor->desc, INotifyFd);
577 mutt_debug(LL_DEBUG3, "inotify_rm_watch for '%s' descriptor=%d\n", info.path,
578 info.monitor->desc);
579
580 monitor_delete(info.monitor);
582
583cleanup:
584 monitor_info_free(&info);
585 monitor_info_free(&info2);
586 return rc;
587}
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
Definition: mailbox.c:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MonitorFilesChanged

bool MonitorFilesChanged = false

Set to true when a monitored file has changed.

true after a monitored file has changed

Definition at line 50 of file monitor.c.

◆ MonitorContextChanged

bool MonitorContextChanged = false

Set to true when the current mailbox has changed.

true after the current mailbox has changed

Definition at line 52 of file monitor.c.

◆ INotifyFd

int INotifyFd = -1
static

Inotify file descriptor.

Definition at line 55 of file monitor.c.

◆ Monitor

struct Monitor* Monitor = NULL
static

Linked list of monitored Mailboxes.

Definition at line 57 of file monitor.c.

◆ PollFdsCount

size_t PollFdsCount = 0
static

Number of used entries in the PollFds array.

Definition at line 59 of file monitor.c.

◆ PollFdsLen

size_t PollFdsLen = 0
static

Size of PollFds array.

Definition at line 61 of file monitor.c.

◆ PollFds

struct pollfd* PollFds = NULL
static

Array of monitored file descriptors.

Definition at line 63 of file monitor.c.

◆ MonitorContextDescriptor

int MonitorContextDescriptor = -1
static

Monitor file descriptor of the current mailbox.

Definition at line 65 of file monitor.c.