Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

353 lines
8.7KB

  1. diff --git a/gio/gthreadedresolver.c b/gio/gthreadedresolver.c
  2. index bd7a829..c24ce6c 100644
  3. --- a/gio/gthreadedresolver.c
  4. +++ b/gio/gthreadedresolver.c
  5. @@ -24,6 +24,7 @@
  6. #include <glib.h>
  7. #include "glibintl.h"
  8. +#include <errno.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11. @@ -527,9 +528,8 @@ do_lookup_service (GThreadedResolverRequest *req,
  12. #endif
  13. #if defined(G_OS_UNIX)
  14. - len = res_query (req->u.service.rrname, C_IN, T_SRV, answer, sizeof (answer));
  15. - herr = h_errno;
  16. - req->u.service.targets = _g_resolver_targets_from_res_query (req->u.service.rrname, answer, len, herr, error);
  17. + herr = -ENOSYS;
  18. + req->u.service.targets = NULL;
  19. #elif defined(G_OS_WIN32)
  20. status = DnsQuery_A (req->u.service.rrname, DNS_TYPE_SRV,
  21. DNS_QUERY_STANDARD, NULL, &results, NULL);
  22. diff --git a/gio/libasyncns/asyncns.c b/gio/libasyncns/asyncns.c
  23. index 3c4db73..5b548f8 100644
  24. --- a/gio/libasyncns/asyncns.c
  25. +++ b/gio/libasyncns/asyncns.c
  26. @@ -179,27 +179,6 @@ typedef struct res_query_response {
  27. int _h_errno;
  28. } res_response_t;
  29. -#ifndef HAVE_STRNDUP
  30. -
  31. -static char *strndup(const char *s, size_t l) {
  32. - size_t a;
  33. - char *n;
  34. -
  35. - a = strlen(s);
  36. - if (a > l)
  37. - a = l;
  38. -
  39. - if (!(n = malloc(a+1)))
  40. - return NULL;
  41. -
  42. - memcpy(n, s, a);
  43. - n[a] = 0;
  44. -
  45. - return n;
  46. -}
  47. -
  48. -#endif
  49. -
  50. #ifndef HAVE_PTHREAD
  51. static int close_allv(const int except_fds[]) {
  52. @@ -595,277 +574,11 @@ static int handle_request(int out_fd, const rheader_t *req, size_t length) {
  53. return 0;
  54. }
  55. -#ifndef HAVE_PTHREAD
  56. -
  57. -static int process_worker(int in_fd, int out_fd) {
  58. - int have_death_sig = 0;
  59. - int good_fds[3];
  60. - int ret = 1;
  61. -
  62. - const int ignore_sigs[] = {
  63. - SIGINT,
  64. - SIGHUP,
  65. - SIGPIPE,
  66. - SIGUSR1,
  67. - SIGUSR2,
  68. - -1
  69. - };
  70. -
  71. - assert(in_fd > 2);
  72. - assert(out_fd > 2);
  73. -
  74. - close(0);
  75. - close(1);
  76. - close(2);
  77. -
  78. - if (open("/dev/null", O_RDONLY) != 0)
  79. - goto fail;
  80. -
  81. - if (open("/dev/null", O_WRONLY) != 1)
  82. - goto fail;
  83. -
  84. - if (open("/dev/null", O_WRONLY) != 2)
  85. - goto fail;
  86. -
  87. - if (chdir("/") < 0)
  88. - goto fail;
  89. -
  90. - if (geteuid() == 0) {
  91. - struct passwd *pw;
  92. - int r;
  93. -
  94. - if ((pw = getpwnam("nobody"))) {
  95. -#ifdef HAVE_SETRESUID
  96. - r = setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid);
  97. -#elif HAVE_SETREUID
  98. - r = setreuid(pw->pw_uid, pw->pw_uid);
  99. -#else
  100. - if ((r = setuid(pw->pw_uid)) >= 0)
  101. - r = seteuid(pw->pw_uid);
  102. -#endif
  103. - if (r < 0)
  104. - goto fail;
  105. - }
  106. - }
  107. -
  108. - if (reset_sigsv(ignore_sigs) < 0)
  109. - goto fail;
  110. -
  111. - if (ignore_sigsv(ignore_sigs) < 0)
  112. - goto fail;
  113. -
  114. - good_fds[0] = in_fd; good_fds[1] = out_fd; good_fds[2] = -1;
  115. - if (close_allv(good_fds) < 0)
  116. - goto fail;
  117. -
  118. -#ifdef PR_SET_PDEATHSIG
  119. - if (prctl(PR_SET_PDEATHSIG, SIGTERM) >= 0)
  120. - have_death_sig = 1;
  121. -#endif
  122. -
  123. - if (!have_death_sig)
  124. - fd_nonblock(in_fd);
  125. -
  126. - while (getppid() > 1) { /* if the parent PID is 1 our parent process died. */
  127. - rheader_t buf[BUFSIZE/sizeof(rheader_t) + 1];
  128. - ssize_t length;
  129. -
  130. - if (!have_death_sig) {
  131. - fd_set fds;
  132. - struct timeval tv = { 0, 500000 };
  133. -
  134. - FD_ZERO(&fds);
  135. - FD_SET(in_fd, &fds);
  136. -
  137. - if (select(in_fd+1, &fds, NULL, NULL, &tv) < 0)
  138. - break;
  139. -
  140. - if (getppid() == 1)
  141. - break;
  142. - }
  143. -
  144. - if ((length = recv(in_fd, buf, sizeof(buf), 0)) <= 0) {
  145. -
  146. - if (length < 0 &&
  147. - (errno == EAGAIN || errno == EINTR))
  148. - continue;
  149. -
  150. - break;
  151. - }
  152. -
  153. - if (handle_request(out_fd, buf, (size_t) length) < 0)
  154. - break;
  155. - }
  156. -
  157. - ret = 0;
  158. -
  159. -fail:
  160. - send_died(out_fd);
  161. -
  162. - return ret;
  163. -}
  164. -
  165. -#else
  166. -
  167. -static void* thread_worker(void *p) {
  168. - _g_asyncns_t *asyncns = p;
  169. - sigset_t fullset;
  170. -
  171. - /* No signals in this thread please */
  172. - sigfillset(&fullset);
  173. - pthread_sigmask(SIG_BLOCK, &fullset, NULL);
  174. -
  175. - while (!asyncns->dead) {
  176. - rheader_t buf[BUFSIZE/sizeof(rheader_t) + 1];
  177. - ssize_t length;
  178. -
  179. - if ((length = recv(asyncns->fds[REQUEST_RECV_FD], buf, sizeof(buf), 0)) <= 0) {
  180. -
  181. - if (length < 0 &&
  182. - (errno == EAGAIN || errno == EINTR))
  183. - continue;
  184. -
  185. - break;
  186. - }
  187. -
  188. - if (asyncns->dead)
  189. - break;
  190. -
  191. - if (handle_request(asyncns->fds[RESPONSE_SEND_FD], buf, (size_t) length) < 0)
  192. - break;
  193. - }
  194. -
  195. - send_died(asyncns->fds[RESPONSE_SEND_FD]);
  196. -
  197. - return NULL;
  198. -}
  199. -
  200. -#endif
  201. -
  202. _g_asyncns_t* _g_asyncns_new(unsigned n_proc) {
  203. - _g_asyncns_t *asyncns = NULL;
  204. - int i;
  205. - assert(n_proc >= 1);
  206. -
  207. - if (n_proc > MAX_WORKERS)
  208. - n_proc = MAX_WORKERS;
  209. -
  210. - if (!(asyncns = malloc(sizeof(_g_asyncns_t)))) {
  211. - errno = ENOMEM;
  212. - goto fail;
  213. - }
  214. -
  215. - asyncns->dead = 0;
  216. - asyncns->valid_workers = 0;
  217. -
  218. - for (i = 0; i < MESSAGE_FD_MAX; i++)
  219. - asyncns->fds[i] = -1;
  220. -
  221. - memset(asyncns->queries, 0, sizeof(asyncns->queries));
  222. -
  223. - if (socketpair(PF_UNIX, SOCK_DGRAM, 0, asyncns->fds) < 0 ||
  224. - socketpair(PF_UNIX, SOCK_DGRAM, 0, asyncns->fds+2) < 0)
  225. - goto fail;
  226. -
  227. - for (i = 0; i < MESSAGE_FD_MAX; i++)
  228. - fd_cloexec(asyncns->fds[i]);
  229. -
  230. - for (asyncns->valid_workers = 0; asyncns->valid_workers < n_proc; asyncns->valid_workers++) {
  231. -
  232. -#ifndef HAVE_PTHREAD
  233. - if ((asyncns->workers[asyncns->valid_workers] = fork()) < 0)
  234. - goto fail;
  235. - else if (asyncns->workers[asyncns->valid_workers] == 0) {
  236. - int ret;
  237. -
  238. - close(asyncns->fds[REQUEST_SEND_FD]);
  239. - close(asyncns->fds[RESPONSE_RECV_FD]);
  240. - ret = process_worker(asyncns->fds[REQUEST_RECV_FD], asyncns->fds[RESPONSE_SEND_FD]);
  241. - close(asyncns->fds[REQUEST_RECV_FD]);
  242. - close(asyncns->fds[RESPONSE_SEND_FD]);
  243. - _exit(ret);
  244. - }
  245. -#else
  246. - int r;
  247. -
  248. - if ((r = pthread_create(&asyncns->workers[asyncns->valid_workers], NULL, thread_worker, asyncns)) != 0) {
  249. - errno = r;
  250. - goto fail;
  251. - }
  252. -#endif
  253. - }
  254. -
  255. -#ifndef HAVE_PTHREAD
  256. - close(asyncns->fds[REQUEST_RECV_FD]);
  257. - close(asyncns->fds[RESPONSE_SEND_FD]);
  258. - asyncns->fds[REQUEST_RECV_FD] = asyncns->fds[RESPONSE_SEND_FD] = -1;
  259. -#endif
  260. -
  261. - asyncns->current_index = asyncns->current_id = 0;
  262. - asyncns->done_head = asyncns->done_tail = NULL;
  263. - asyncns->n_queries = 0;
  264. -
  265. - fd_nonblock(asyncns->fds[RESPONSE_RECV_FD]);
  266. -
  267. - return asyncns;
  268. -
  269. -fail:
  270. - if (asyncns)
  271. - _g_asyncns_free(asyncns);
  272. -
  273. return NULL;
  274. }
  275. void _g_asyncns_free(_g_asyncns_t *asyncns) {
  276. - int i;
  277. - int saved_errno = errno;
  278. - unsigned p;
  279. -
  280. - assert(asyncns);
  281. -
  282. - asyncns->dead = 1;
  283. -
  284. - if (asyncns->fds[REQUEST_SEND_FD] >= 0) {
  285. - rheader_t req;
  286. -
  287. - memset(&req, 0, sizeof(req));
  288. - req.type = REQUEST_TERMINATE;
  289. - req.length = sizeof(req);
  290. - req.id = 0;
  291. -
  292. - /* Send one termination packet for each worker */
  293. - for (p = 0; p < asyncns->valid_workers; p++)
  294. - send(asyncns->fds[REQUEST_SEND_FD], &req, req.length, MSG_NOSIGNAL);
  295. - }
  296. -
  297. - /* Now terminate them and wait until they are gone. */
  298. - for (p = 0; p < asyncns->valid_workers; p++) {
  299. -#ifndef HAVE_PTHREAD
  300. - kill(asyncns->workers[p], SIGTERM);
  301. - for (;;) {
  302. - if (waitpid(asyncns->workers[p], NULL, 0) >= 0 || errno != EINTR)
  303. - break;
  304. - }
  305. -#else
  306. - for (;;) {
  307. - if (pthread_join(asyncns->workers[p], NULL) != EINTR)
  308. - break;
  309. - }
  310. -#endif
  311. - }
  312. -
  313. - /* Close all communication channels */
  314. - for (i = 0; i < MESSAGE_FD_MAX; i++)
  315. - if (asyncns->fds[i] >= 0)
  316. - close(asyncns->fds[i]);
  317. -
  318. - for (p = 0; p < MAX_QUERIES; p++)
  319. - if (asyncns->queries[p])
  320. - _g_asyncns_cancel(asyncns, asyncns->queries[p]);
  321. -
  322. - free(asyncns);
  323. -
  324. - errno = saved_errno;
  325. }
  326. int _g_asyncns_fd(_g_asyncns_t *asyncns) {
  327. diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
  328. index e9e82dd..ed85260 100644
  329. --- a/gio/gdesktopappinfo.c
  330. +++ b/gio/gdesktopappinfo.c
  331. @@ -2356,13 +2356,6 @@ mime_info_cache_dir_add_desktop_entries (MimeInfoCacheDir *dir,
  332. desktop_file_ids = g_hash_table_lookup (dir->mime_info_cache_map,
  333. mime_type);
  334. - for (i = 0; new_desktop_file_ids[i] != NULL; i++)
  335. - {
  336. - if (!g_list_find_custom (desktop_file_ids, new_desktop_file_ids[i], strcmp))
  337. - desktop_file_ids = g_list_append (desktop_file_ids,
  338. - g_strdup (new_desktop_file_ids[i]));
  339. - }
  340. -
  341. g_hash_table_insert (dir->mime_info_cache_map, g_strdup (mime_type), desktop_file_ids);
  342. }