Changeset 23378
- Timestamp:
- 09/13/07 10:16:54 (15 months ago)
- Location:
- trunk/launchd/src
- Files:
-
- 6 modified
-
launchctl.c (modified) (5 diffs)
-
launchd.c (modified) (1 diff)
-
launchd_core_logic.c (modified) (8 diffs)
-
launchd_runtime.c (modified) (2 diffs)
-
launchproxy.c (modified) (2 diffs)
-
liblaunch.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/launchctl.c
r23348 r23378 82 82 #define MACHINIT_JOBKEY_SERVICEPORT "ServicePort" 83 83 84 #define assumes(e) \85 (__builtin_expect(!(e), 0) ? _log_launchctl_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true)84 #define assumes(e) \ 85 (__builtin_expect(!(e), 0) ? _log_launchctl_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true) 86 86 87 87 … … 739 739 740 740 if (!(S_ISREG(sb.st_mode) || S_ISDIR(sb.st_mode))) { 741 fprintf(stderr, "%s: Dubious path. Not a regular file or directory (skipping): %s\n", getprogname(), path);741 fprintf(stderr, "%s: Dubious path. Not a regular file or directory (skipping): %s\n", getprogname(), path); 742 742 return false; 743 743 } … … 895 895 } 896 896 897 if (passive) { 897 if (passive) { 898 898 if (unlink(sun.sun_path) == -1 && errno != ENOENT) { 899 close(sfd); 899 close(sfd); 900 900 return; 901 901 } … … 1622 1622 load_and_unload_cmd(int argc, char *const argv[]) 1623 1623 { 1624 NSSearchPathEnumerationState es = 0;1624 NSSearchPathEnumerationState es = 0; 1625 1625 char nspath[PATH_MAX * 2]; /* safe side, we need to append */ 1626 1626 bool badopts = false; … … 2596 2596 { 2597 2597 bool has_servicename = launch_data_dict_lookup(obj, MACHINIT_JOBKEY_SERVICENAME); 2598 bool has_command = launch_data_dict_lookup(obj, MACHINIT_JOBKEY_COMMAND);2598 bool has_command = launch_data_dict_lookup(obj, MACHINIT_JOBKEY_COMMAND); 2599 2599 bool has_label = launch_data_dict_lookup(obj, LAUNCH_JOBKEY_LABEL); 2600 2600 -
trunk/launchd/src/launchd.c
r23356 r23378 116 116 while ((ch = getopt(argc, argv, "s")) != -1) { 117 117 switch (ch) { 118 case 's': sflag = true; break; /* single user */118 case 's': sflag = true; break; /* single user */ 119 119 case '?': /* we should do something with the global optopt variable here */ 120 120 default: -
trunk/launchd/src/launchd_core_logic.c
r23377 r23378 274 274 }; 275 275 276 #define jobmgr_assumes(jm, e) \277 (__builtin_expect(!(e), 0) ? jobmgr_log_bug(jm, __rcs_file_version__, __FILE__, __LINE__, #e), false : true)276 #define jobmgr_assumes(jm, e) \ 277 (__builtin_expect(!(e), 0) ? jobmgr_log_bug(jm, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) 278 278 279 279 static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name); … … 370 370 371 371 372 #define job_assumes(j, e) \373 (__builtin_expect(!(e), 0) ? job_log_bug(j, __rcs_file_version__, __FILE__, __LINE__, #e), false : true)372 #define job_assumes(j, e) \ 373 (__builtin_expect(!(e), 0) ? job_log_bug(j, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) 374 374 375 375 static void job_import_keys(launch_data_t obj, const char *key, void *context); … … 422 422 int val; 423 423 } launchd_keys2limits[] = { 424 { LAUNCH_JOBKEY_RESOURCELIMIT_CORE, RLIMIT_CORE},425 { LAUNCH_JOBKEY_RESOURCELIMIT_CPU, RLIMIT_CPU},426 { LAUNCH_JOBKEY_RESOURCELIMIT_DATA, RLIMIT_DATA},427 { LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE, RLIMIT_FSIZE},428 { LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK, RLIMIT_MEMLOCK},429 { LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE, RLIMIT_NOFILE},430 { LAUNCH_JOBKEY_RESOURCELIMIT_NPROC, RLIMIT_NPROC},431 { LAUNCH_JOBKEY_RESOURCELIMIT_RSS, RLIMIT_RSS},432 { LAUNCH_JOBKEY_RESOURCELIMIT_STACK, RLIMIT_STACK},424 { LAUNCH_JOBKEY_RESOURCELIMIT_CORE, RLIMIT_CORE }, 425 { LAUNCH_JOBKEY_RESOURCELIMIT_CPU, RLIMIT_CPU }, 426 { LAUNCH_JOBKEY_RESOURCELIMIT_DATA, RLIMIT_DATA }, 427 { LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE, RLIMIT_FSIZE }, 428 { LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK, RLIMIT_MEMLOCK }, 429 { LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE, RLIMIT_NOFILE }, 430 { LAUNCH_JOBKEY_RESOURCELIMIT_NPROC, RLIMIT_NPROC }, 431 { LAUNCH_JOBKEY_RESOURCELIMIT_RSS, RLIMIT_RSS }, 432 { LAUNCH_JOBKEY_RESOURCELIMIT_STACK, RLIMIT_STACK }, 433 433 }; 434 434 … … 717 717 jobmgr_log(jm, LOG_DEBUG, "About to call: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags)); 718 718 runtime_closelog(); 719 jobmgr_assumes(jm, reboot(jm->reboot_flags) != -1);719 jobmgr_assumes(jm, reboot(jm->reboot_flags) != -1); 720 720 runtime_closelog(); 721 721 } else { … … 3071 3071 } 3072 3072 3073 void 3073 void 3074 3074 semaphoreitem_ignore(job_t j, struct semaphoreitem *si) 3075 { 3075 { 3076 3076 if (si->fd != -1) { 3077 3077 job_log(j, LOG_DEBUG, "Ignoring Vnode: %d", si->fd); … … 4337 4337 } 4338 4338 4339 #define NELEM(x) (sizeof(x)/sizeof(x[0]))4340 #define END_OF(x) (&(x)[NELEM(x)])4339 #define NELEM(x) (sizeof(x)/sizeof(x[0])) 4340 #define END_OF(x) (&(x)[NELEM(x)]) 4341 4341 4342 4342 char ** … … 4738 4738 } 4739 4739 4740 if (mon < wtm->tm_mon) {4740 if (mon < wtm->tm_mon) { 4741 4741 return false; 4742 4742 } 4743 4743 4744 if (mon > wtm->tm_mon) {4744 if (mon > wtm->tm_mon) { 4745 4745 wtm->tm_mon = mon; 4746 4746 wtm->tm_mday = 1; … … 4773 4773 } 4774 4774 4775 if (mday < wtm->tm_mday) {4775 if (mday < wtm->tm_mday) { 4776 4776 return false; 4777 4777 } 4778 4778 4779 if (mday > wtm->tm_mday) {4779 if (mday > wtm->tm_mday) { 4780 4780 wtm->tm_mday = mday; 4781 4781 wtm->tm_hour = 0; -
trunk/launchd/src/launchd_runtime.c
r23376 r23378 143 143 pthread_attr_destroy(&attr); 144 144 145 pthread_attr_init(&attr);145 pthread_attr_init(&attr); 146 146 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 147 147 pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); … … 1174 1174 struct logmsg_s *lm; 1175 1175 1176 #define ROUND_TO_64BIT_WORD_SIZE(x) ((x + 7) & ~7)1176 #define ROUND_TO_64BIT_WORD_SIZE(x) ((x + 7) & ~7) 1177 1177 1178 1178 /* we do this to make the unpacking for the log_drain cause unalignment faults */ -
trunk/launchd/src/launchproxy.c
r20793 r23378 49 49 static void find_fds(launch_data_t o, const char *key __attribute__((unused)), void *context __attribute__((unused))) 50 50 { 51 struct kevent kev;52 size_t i;51 struct kevent kev; 52 size_t i; 53 53 int fd; 54 54 55 switch (launch_data_get_type(o)) {56 case LAUNCH_DATA_FD:55 switch (launch_data_get_type(o)) { 56 case LAUNCH_DATA_FD: 57 57 fd = launch_data_get_fd(o); 58 58 if (-1 == fd) … … 62 62 if (kevent(kq, &kev, 1, NULL, 0, NULL) == -1) 63 63 syslog(LOG_DEBUG, "kevent(%d): %m", fd); 64 break;65 case LAUNCH_DATA_ARRAY:66 for (i = 0; i < launch_data_array_get_count(o); i++)67 find_fds(launch_data_array_get_index(o, i), NULL, NULL);68 break;69 case LAUNCH_DATA_DICTIONARY:70 launch_data_dict_iterate(o, find_fds, NULL);71 break;72 default:73 break;74 }64 break; 65 case LAUNCH_DATA_ARRAY: 66 for (i = 0; i < launch_data_array_get_count(o); i++) 67 find_fds(launch_data_array_get_index(o, i), NULL, NULL); 68 break; 69 case LAUNCH_DATA_DICTIONARY: 70 launch_data_dict_iterate(o, find_fds, NULL); 71 break; 72 default: 73 break; 74 } 75 75 } 76 76 -
trunk/launchd/src/liblaunch.c
r23274 r23378 373 373 { 374 374 launch_data_t r = NULL; 375 375 376 376 if (where->_array_cnt > 0) { 377 377 r = where->_array[0]; … … 526 526 launchd_fdopen(int fd) 527 527 { 528 launch_t c;529 530 c = calloc(1, sizeof(struct _launch));528 launch_t c; 529 530 c = calloc(1, sizeof(struct _launch)); 531 531 if (!c) 532 532 return NULL; 533 533 534 c->fd = fd;534 c->fd = fd; 535 535 536 536 fcntl(fd, F_SETFL, O_NONBLOCK); 537 537 538 if ((c->sendbuf = malloc(0)) == NULL)538 if ((c->sendbuf = malloc(0)) == NULL) 539 539 goto out_bad; 540 if ((c->sendfds = malloc(0)) == NULL)540 if ((c->sendfds = malloc(0)) == NULL) 541 541 goto out_bad; 542 if ((c->recvbuf = malloc(0)) == NULL)542 if ((c->recvbuf = malloc(0)) == NULL) 543 543 goto out_bad; 544 if ((c->recvfds = malloc(0)) == NULL)544 if ((c->recvfds = malloc(0)) == NULL) 545 545 goto out_bad; 546 546 … … 771 771 iov[0].iov_len = sizeof(lmh); 772 772 mh.msg_iov = iov; 773 mh.msg_iovlen = 2;773 mh.msg_iovlen = 2; 774 774 } else { 775 775 mh.msg_iov = iov + 1; 776 mh.msg_iovlen = 1;776 mh.msg_iovlen = 1; 777 777 } 778 778 … … 917 917 } while (launchd_msg_send(_lc->l, NULL) == -1); 918 918 } 919 919 920 920 while (resp == NULL) { 921 921 if (d == NULL && launch_data_array_get_count(_lc->async_resp) > 0) { … … 951 951 launch_data_t rmsg = NULL; 952 952 size_t data_offset, fd_offset; 953 struct msghdr mh;954 struct iovec iov;953 struct msghdr mh; 954 struct iovec iov; 955 955 int r; 956 956 957 memset(&mh, 0, sizeof(mh));958 mh.msg_iov = &iov;959 mh.msg_iovlen = 1;957 memset(&mh, 0, sizeof(mh)); 958 mh.msg_iov = &iov; 959 mh.msg_iovlen = 1; 960 960 961 961 lh->recvbuf = reallocf(lh->recvbuf, lh->recvlen + 8*1024); … … 1100 1100 1101 1101 if (r) 1102 launch_data_set_errno(r, e);1102 launch_data_set_errno(r, e); 1103 1103 1104 1104 return r; … … 1110 1110 1111 1111 if (r) 1112 launch_data_set_fd(r, fd);1112 launch_data_set_fd(r, fd); 1113 1113 1114 1114 return r; … … 1120 1120 1121 1121 if (r) 1122 launch_data_set_machport(r, p);1122 launch_data_set_machport(r, p); 1123 1123 1124 1124 return r;

