Changeset 7c2bb2c in mainline for uspace/srv/hid/remcons/remcons.c
- Timestamp:
- 2012-01-10T14:59:39Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1870d81
- Parents:
- 3806317
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/remcons/remcons.c
r3806317 r7c2bb2c 336 336 } 337 337 338 339 static int network_client_fibril(void *arg) 340 { 338 static int spawn_task_fibril(void *arg) 339 { 340 client_t *client = arg; 341 341 int rc; 342 client_t *client = arg;343 344 rc = loc_service_register(client->service_name, &client->service_id);345 if (rc != EOK) {346 fprintf(stderr, "%s: Unable to register device %s\n", NAME,347 client->service_name);348 return EOK;349 }350 printf("Service %s registered as %" PRIun "\n", client->service_name,351 client->service_id);352 342 353 343 char term[LOC_NAME_MAXLEN]; … … 359 349 printf("%s: Error spawning %s -w %s %s (%s)\n", NAME, 360 350 APP_GETTERM, term, "/app/bdsh", str_error(rc)); 351 fibril_mutex_lock(&client->refcount_mutex); 352 client->refcount--; 353 fibril_condvar_signal(&client->refcount_cv); 354 fibril_mutex_unlock(&client->refcount_mutex); 361 355 return EOK; 362 356 } 363 fibril_mutex_lock(&client->refcount_mutex);364 client->refcount++;365 fibril_mutex_unlock(&client->refcount_mutex);366 357 367 358 task_exit_t task_exit; … … 370 361 printf("%s: getterm terminated: %d, %d\n", NAME, task_exit, task_retval); 371 362 363 /* Announce destruction. */ 364 fibril_mutex_lock(&client->refcount_mutex); 365 client->refcount--; 366 fibril_condvar_signal(&client->refcount_cv); 367 fibril_mutex_unlock(&client->refcount_mutex); 368 369 return EOK; 370 } 371 372 373 static int network_client_fibril(void *arg) 374 { 375 int rc; 376 client_t *client = arg; 377 378 rc = loc_service_register(client->service_name, &client->service_id); 379 if (rc != EOK) { 380 fprintf(stderr, "%s: Unable to register device %s\n", NAME, 381 client->service_name); 382 return EOK; 383 } 384 printf("Service %s registered as %" PRIun "\n", client->service_name, 385 client->service_id); 386 387 fibril_mutex_lock(&client->refcount_mutex); 388 client->refcount++; 389 fibril_mutex_unlock(&client->refcount_mutex); 390 391 fid_t spawn_fibril = fibril_create(spawn_task_fibril, client); 392 assert(spawn_fibril); 393 fibril_add_ready(spawn_fibril); 394 395 /* Wait for all clients to exit. */ 396 fibril_mutex_lock(&client->refcount_mutex); 397 while (client->refcount > 0) { 398 fibril_condvar_wait(&client->refcount_cv, &client->refcount_mutex); 399 } 400 fibril_mutex_unlock(&client->refcount_mutex); 401 372 402 closesocket(client->socket); 373 403 rc = loc_service_unregister(client->service_id); … … 376 406 } 377 407 378 /* Wait for all clients to exit. */ 379 fibril_mutex_lock(&client->refcount_mutex); 380 /* Drop our reference. */ 381 client->refcount--; 382 while (client->refcount > 0) { 383 fibril_condvar_wait(&client->refcount_cv, &client->refcount_mutex); 384 } 385 fibril_mutex_unlock(&client->refcount_mutex); 386 408 printf("Destroying service %s.\n", client->service_name); 387 409 client_destroy(client); 388 410
Note:
See TracChangeset
for help on using the changeset viewer.