Univention Bugzilla – Attachment 7816 Details for
Bug 39775
libnss-extrausers not thread safe? - prevents libvirt from starting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Test program
39775_extrausers.c (text/plain), 1.81 KB, created by
Philipp Hahn
on 2016-07-19 18:29:51 CEST
(
hide
)
Description:
Test program
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2016-07-19 18:29:51 CEST
Size:
1.81 KB
patch
obsolete
>/* > * Create dead-lock and print debugging data. > */ >#define _GNU_SOURCE >#include <stdlib.h> >#include <stdio.h> >#include <unistd.h> >#include <pthread.h> >#include <grp.h> > >#define ARRAY_SIZE(a) ((sizeof (a)) / sizeof (*(a))) >#define BUFLEN 4096 >#define GROUPS 100 > >static pthread_t thread[100]; > >static const char user[] = "Administrator"; > >static void *run(void *data) { > unsigned int round; > > unsigned int self = (unsigned int)(unsigned long)data; > pthread_t tid = pthread_self(); > > printf("[%d] POSIX thread ID is %u\n", self, (unsigned int)tid); > > for (round = 0; round < 100; round++) { >#if 0 > setgrent(); > while (1) { > int i; > char buf[BUFLEN]; > struct group grp, *grpp; > > i = getgrent_r(&grp, buf, BUFLEN, &grpp); > if (i) > break; > printf("%s (%d):", grpp->gr_name, grpp->gr_gid); > for (i = 0; ; i++) { > if (grpp->gr_mem[i] == NULL) > break; > printf("."); > // printf(" %s", grpp->gr_mem[i]); > } > printf("\n"); > } > endgrent(); >#else > int r, ngroups = GROUPS; > gid_t group = 0, groups[GROUPS]; > > r = getgrouplist(user, group, groups, &ngroups); > if (r < 0 || ngroups < 0 || ngroups >= GROUPS) { > printf("r=%d g=%d\n", r, ngroups); > } else { > int i; > for (i = 0; i < ngroups; i++) > printf("%d ", groups[i]); > } >#endif > > unsigned int usecs = (round * (unsigned int)tid) % 100000; > usleep(usecs); > if (round % 10 == 0) > putchar('0' + (self % 10)); > } > > printf("[%d] end\n", self); > pthread_exit(NULL); >} > >int main(int argc, char *argv[], char *envp[]) { > pid_t pid = getpid(); > printf("pid=%d\n", pid); > > unsigned int t; > for (t = 0; t < ARRAY_SIZE(thread); t++) > pthread_create(&thread[t], NULL, run, (void *)(long)t); > > int ret = 0; > void *value_ptr; > for (t = 0; t < ARRAY_SIZE(thread); t++) > ret |= pthread_join(thread[t], &value_ptr); > > return ret; >} >/* :!gcc -O0 -g -Wall -lpthread % */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 39775
: 7816