void servproc(void *cookie, char *dataptr, size_t datasize, door_desc_t *descptr, size_t ndesc) { long arg, result; printf("thread id %ld called\n", pr_thread_id(NULL)); sleep(6); /* let client catch SIGCHLD */ arg = *((long *) dataptr); result = arg * arg; printf("thread id %ld returning\n", pr_thread_id(NULL)); Door_return((char *) &result, sizeof(result), NULL, 0); }
void server(void *cookie, char *argp, size_t arg_size, door_desc_t *dp, size_t n_descriptors) { long *arg, result[4]; door_cred_t info; if (argp == DOOR_UNREF_DATA) { printf("door unreferenced\n"); Door_return(NULL, 0, NULL, 0); } printf("server called, thread id %ld, %d bytes of arguments, cookie = %p\n", pr_thread_id(NULL), arg_size, cookie); sleep(3); Door_cred(&info); printf("euid = %ld, ruid = %ld, pid = %ld\n", (long) info.dc_euid, (long) info.dc_ruid, (long) info.dc_pid); arg = (long *) argp; printf("arg[0] = %ld, arg[1] = %ld, arg[2] = %ld, arg[3]= %ld\n\n", arg[0], arg[1], arg[2], arg[3]); result[0] = arg[0] * arg[0]; result[1] = arg[1] * arg[1]; result[2] = arg[2] * arg[2]; result[3] = arg[3] * arg[3]; Door_return((char *) result, sizeof(result), NULL, 0); }
void servproc(void *cookie, char *dataptr, size_t datasize, door_desc_t *descptr, size_t ndesc) { long arg, result; if (dataptr == DOOR_UNREF_DATA) { printf("door unreferenced\n"); Door_return(NULL, 0, NULL, 0); } arg = *((long *) dataptr); printf("thread id %ld, arg = %ld\n", pr_thread_id(NULL), arg); sleep(6); result = arg * arg; printf("thread id %ld returning\n", pr_thread_id(NULL)); Door_return((char *) &result, sizeof(result), NULL, 0); }
void servproc(void *cookie, char *dataptr, size_t datasize, door_desc_t *descptr, size_t ndesc) { long arg, result; Door_revoke(*((int *) cookie)); arg = *((long *) dataptr); printf("thread id %ld, arg = %ld\n", pr_thread_id(NULL), arg); result = arg * arg; Door_return((char *) &result, sizeof(result), NULL, 0); }
void my_create(door_info_t *iptr) { pthread_t tid; pthread_attr_t attr; printf("tserver1: iptr = %p\n", iptr); Pthread_attr_init(&attr); Pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); Pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); Pthread_create(&tid, &attr, my_thread, (void *) iptr->di_proc); Pthread_attr_destroy(&attr); printf("created server thread %ld\n", pr_thread_id(&tid)); }
void servproc_cleanup(void *arg) { printf("servproc cancelled, thread id %ld\n", pr_thread_id(NULL)); }