static void release_endpoint(struct media_endpoint *endpoint) { DBusMessage *msg; DBG("sender=%s path=%s", endpoint->sender, endpoint->path); /* already exit */ if (endpoint->watch == 0) goto done; clear_endpoint(endpoint); msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, MEDIA_ENDPOINT_INTERFACE, "Release"); if (msg == NULL) { error("Couldn't allocate D-Bus message"); return; } g_dbus_send_message(btd_get_dbus_connection(), msg); done: media_endpoint_remove(endpoint); }
static void clear_interface(struct libusb_interface *usb_interface) { int i; int j; if (usb_interface->altsetting) { for (i = 0; i < usb_interface->num_altsetting; i++) { struct libusb_interface_descriptor *ifp = (struct libusb_interface_descriptor *) usb_interface->altsetting + i; if (ifp->extra) free((void *) ifp->extra); if (ifp->endpoint) { for (j = 0; j < ifp->bNumEndpoints; j++) clear_endpoint((struct libusb_endpoint_descriptor *) ifp->endpoint + j); free((void *) ifp->endpoint); } } free((void *) usb_interface->altsetting); usb_interface->altsetting = NULL; } }
/*===========================================================================* * do_clear * *===========================================================================*/ int do_clear(struct proc * caller, message * m_ptr) { /* Handle sys_clear. Only the PM can request other process slots to be cleared * when a process has exited. * The routine to clean up a process table slot cancels outstanding timers, * possibly removes the process from the message queues, and resets certain * process table fields to the default values. */ struct proc *rc; int exit_p; int i; if(!isokendpt(m_ptr->PR_ENDPT, &exit_p)) { /* get exiting process */ return EINVAL; } rc = proc_addr(exit_p); /* clean up */ release_address_space(rc); /* Don't clear if already cleared. */ if(isemptyp(rc)) return OK; /* Check the table with IRQ hooks to see if hooks should be released. */ for (i=0; i < NR_IRQ_HOOKS; i++) { if (rc->p_endpoint == irq_hooks[i].proc_nr_e) { rm_irq_handler(&irq_hooks[i]); /* remove interrupt handler */ irq_hooks[i].proc_nr_e = NONE; /* mark hook as free */ } } /* Remove the process' ability to send and receive messages */ clear_endpoint(rc); /* Turn off any alarm timers at the clock. */ reset_timer(&priv(rc)->s_alarm_timer); /* Make sure that the exiting process is no longer scheduled, * and mark slot as FREE. Also mark saved fpu contents as not significant. */ RTS_SETFLAGS(rc, RTS_SLOT_FREE); /* release FPU */ release_fpu(rc); rc->p_misc_flags &= ~MF_FPU_INITIALIZED; /* Release the process table slot. If this is a system process, also * release its privilege structure. Further cleanup is not needed at * this point. All important fields are reinitialized when the * slots are assigned to another, new process. */ if (priv(rc)->s_flags & SYS_PROC) priv(rc)->s_proc_nr = NONE; #if 0 /* Clean up virtual memory */ if (rc->p_misc_flags & MF_VM) { vm_map_default(rc); } #endif return OK; }
static void clear_config(struct a2dp_sep *sep, void *user_data) { struct media_endpoint *endpoint = user_data; clear_endpoint(endpoint); }
static void endpoint_reply(DBusPendingCall *call, void *user_data) { struct endpoint_request *request = user_data; struct media_endpoint *endpoint = request->endpoint; DBusMessage *reply; DBusError err; gboolean value; void *ret = NULL; int size = -1; /* steal_reply will always return non-NULL since the callback * is only called after a reply has been received */ reply = dbus_pending_call_steal_reply(call); dbus_error_init(&err); if (dbus_set_error_from_message(&err, reply)) { error("Endpoint replied with an error: %s", err.name); /* Clear endpoint configuration in case of NO_REPLY error */ if (dbus_error_has_name(&err, DBUS_ERROR_NO_REPLY)) { if (request->cb) request->cb(endpoint, NULL, size, request->user_data); clear_endpoint(endpoint); dbus_message_unref(reply); dbus_error_free(&err); return; } dbus_error_free(&err); goto done; } if (dbus_message_is_method_call(request->msg, MEDIA_ENDPOINT_INTERFACE, "SelectConfiguration")) { DBusMessageIter args, array; uint8_t *configuration; dbus_message_iter_init(reply, &args); dbus_message_iter_recurse(&args, &array); dbus_message_iter_get_fixed_array(&array, &configuration, &size); ret = configuration; goto done; } else if (!dbus_message_get_args(reply, &err, DBUS_TYPE_INVALID)) { error("Wrong reply signature: %s", err.message); dbus_error_free(&err); goto done; } size = 1; value = TRUE; ret = &value; done: dbus_message_unref(reply); if (request->cb) request->cb(endpoint, ret, size, request->user_data); endpoint->requests = g_slist_remove(endpoint->requests, request); endpoint_request_free(request); }