Changeset 373 for trunk/src/sh_inotify.c
- Timestamp:
- Nov 1, 2011, 9:29:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_inotify.c
r372 r373 128 128 short type; 129 129 int class; 130 int rdepth; 130 131 unsigned long check_mask; 131 132 char * file; … … 245 246 } 246 247 247 static sh_watch * sh_inotify_create_watch(c har * file, int nwatch, int flag)248 static sh_watch * sh_inotify_create_watch(const char * file, int nwatch, int flag) 248 249 { 249 250 sh_watch * this = SH_ALLOC(sizeof(sh_watch)); … … 356 357 357 358 char * sh_inotify_pop_dormant(sh_watches * watches, 358 int * class, unsigned long * check_mask, int * type) 359 int * class, unsigned long * check_mask, 360 int * type, int * rdepth) 359 361 { 360 362 char * popret = NULL; … … 372 374 if (this) 373 375 { 374 *class = this->watch->class; 375 *type = this->watch->type; 376 *class = this->watch->class; 377 *type = this->watch->type; 378 *rdepth = this->watch->rdepth; 376 379 *check_mask = this->watch->check_mask; 377 popret = sh_util_strdup(this->watch->file);380 popret = sh_util_strdup(this->watch->file); 378 381 379 382 watches->dormant_watches = this->next; … … 472 475 /* Create an item and put it on the 'dormant' list for later watch creation 473 476 */ 474 int sh_inotify_add_watch_later(c har * filename, sh_watches * watches,477 int sh_inotify_add_watch_later(const char * filename, sh_watches * watches, 475 478 int * errnum, 476 int class, unsigned long check_mask, int type )479 int class, unsigned long check_mask, int type, int rdepth) 477 480 { 478 481 sh_watch * item; … … 482 485 item->class = class; 483 486 item->type = (short) type; 487 item->rdepth = (short) rdepth; 484 488 item->check_mask = check_mask; 485 489 … … 574 578 */ 575 579 int sh_inotify_add_watch(char * filename, sh_watches * watches, int * errnum, 576 int class, unsigned long check_mask, int type )580 int class, unsigned long check_mask, int type, int rdepth) 577 581 { 578 582 volatile int retval = 0; … … 618 622 item->class = class; 619 623 item->type = type; 624 item->rdepth = rdepth; 620 625 item->check_mask = check_mask; 621 626 … … 646 651 ++(watches->count); 647 652 } 653 else if (type == SH_INOTIFY_DIR) /* watch exists */ 654 { 655 /* This covers the case that a directory has been added, 656 * but is watched as file at first because it is also 657 * specified as file in the config. 658 */ 659 item = zAVLSearch(watches->list_of_watches, &index); 660 661 if (item && item->type == SH_INOTIFY_FILE) 662 { 663 item->type = SH_INOTIFY_DIR; 664 } 665 } 648 666 } 649 667 retpoint: … … 655 673 656 674 char * sh_inotify_search_item(sh_watches * watches, int watch, 657 int * class, unsigned long * check_mask, int * type) 675 int * class, unsigned long * check_mask, 676 int * type, int * rdepth) 658 677 { 659 678 sh_watch * item; … … 673 692 *check_mask = item->check_mask; 674 693 *type = item->type; 694 *rdepth = item->rdepth; 675 695 sret = sh_util_strdup(item->file); 676 696 } … … 710 730 if (filename) 711 731 { 712 if (sh_inotify_add_watch(filename, watches, errnum, 0, 0, SH_INOTIFY_FILE) < 0) 732 if (sh_inotify_add_watch(filename, watches, errnum, 733 0, 0, SH_INOTIFY_FILE, 0) < 0) 713 734 { 714 735 retry_msleep(waitsec, 0); … … 841 862 842 863 int sh_inotify_add_watch(char * filename, sh_watches * watches, int * errnum, 843 int class, unsigned long check_mask )864 int class, unsigned long check_mask, int type, int rdepth) 844 865 { 845 866 (void) filename; … … 847 868 (void) class; 848 869 (void) check_mask; 870 (void) type; 871 (void) rdepth; 849 872 *errnum = 0; 850 873 return 0; 851 874 } 852 875 853 int sh_inotify_add_watch_later(c har * filename, sh_watches * watches,876 int sh_inotify_add_watch_later(const char * filename, sh_watches * watches, 854 877 int * errnum, 855 int class, unsigned long check_mask )878 int class, unsigned long check_mask, int type, int rdepth) 856 879 { 857 880 (void) filename; … … 859 882 (void) class; 860 883 (void) check_mask; 884 (void) type; 885 (void) rdepth; 861 886 *errnum = 0; 862 887 return 0; … … 876 901 char * p; 877 902 int class; 903 int type; 904 int rdepth; 878 905 unsigned long check_mask; 879 906 int nrun = 0; 880 907 881 sh_watch aw1 = { -1, 0, 1, 1, "a1" };882 sh_watch aw2 = { -1, 0, 2, 1, "a2" };883 sh_watch aw3 = { 2, 0, 3, 1, "a3" };884 sh_watch aw4 = { -1, 0, 4, 1, "a4" };885 sh_watch aw5 = { 5, 0, 5, 1, "a5" };908 sh_watch aw1 = { -1, 0, 0, 1, 99, 1, "a1" }; 909 sh_watch aw2 = { -1, 0, 0, 2, 99, 1, "a2" }; 910 sh_watch aw3 = { 2, 0, 0, 3, 99, 1, "a3" }; 911 sh_watch aw4 = { -1, 0, 0, 4, 99, 1, "a4" }; 912 sh_watch aw5 = { 5, 0, 0, 5, 99, 1, "a5" }; 886 913 887 914 do { … … 971 998 CuAssertIntEquals(tc, count, 5); 972 999 973 p = sh_inotify_pop_dormant(&twatch, &class, &check_mask );1000 p = sh_inotify_pop_dormant(&twatch, &class, &check_mask, &type, &rdepth); 974 1001 CuAssertStrEquals(tc, p, "a5"); 975 1002 976 p = sh_inotify_pop_dormant(&twatch, &class, &check_mask );1003 p = sh_inotify_pop_dormant(&twatch, &class, &check_mask, &type, &rdepth); 977 1004 CuAssertStrEquals(tc, p, "a3"); 978 1005 CuAssertIntEquals(tc, class, 3); 979 1006 980 p = sh_inotify_pop_dormant(&twatch, &class, &check_mask );1007 p = sh_inotify_pop_dormant(&twatch, &class, &check_mask, &type, &rdepth); 981 1008 CuAssertTrue(tc, NULL == p); 982 1009 CuAssertTrue(tc, NULL == twatch.dormant_watches);
Note:
See TracChangeset
for help on using the changeset viewer.