Changeset 07d4271 in mainline for kernel/generic/src/ipc/kbox.c
- Timestamp:
- 2024-01-25T16:22:55Z (16 months ago)
- Branches:
- master
- Children:
- f8b69a1e
- Parents:
- 1a1e124
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-25 15:56:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-25 16:22:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/kbox.c
r1a1e124 r07d4271 200 200 /** Connect phone to a task kernel-box specified by id. 201 201 * 202 * Note that this is not completely atomic. For optimisation reasons, the task203 * might start cleaning up kbox after the phone has been connected and before204 * a kbox thread has been created. This must be taken into account in the205 * cleanup code.206 *207 202 * @param[out] out_phone Phone capability handle on success. 208 203 * @return Error code. … … 211 206 errno_t ipc_connect_kbox(task_id_t taskid, cap_phone_handle_t *out_phone) 212 207 { 213 irq_spinlock_lock(&tasks_lock, true);214 215 208 task_t *task = task_find_by_id(taskid); 216 if (task == NULL) { 217 irq_spinlock_unlock(&tasks_lock, true); 209 if (!task) 218 210 return ENOENT; 219 }220 221 atomic_inc(&task->refcount);222 223 irq_spinlock_unlock(&tasks_lock, true);224 211 225 212 mutex_lock(&task->kb.cleanup_lock); 226 227 if (atomic_predec(&task->refcount) == 0) {228 mutex_unlock(&task->kb.cleanup_lock);229 task_destroy(task);230 return ENOENT;231 }232 213 233 214 if (task->kb.finished) { 234 215 mutex_unlock(&task->kb.cleanup_lock); 216 task_release(task); 235 217 return EINVAL; 236 218 } … … 243 225 if (!kb_thread) { 244 226 mutex_unlock(&task->kb.cleanup_lock); 227 task_release(task); 245 228 return ENOMEM; 246 229 } … … 255 238 if (rc != EOK) { 256 239 mutex_unlock(&task->kb.cleanup_lock); 240 task_release(task); 257 241 return rc; 258 242 } … … 265 249 266 250 mutex_unlock(&task->kb.cleanup_lock); 251 task_release(task); 267 252 *out_phone = phone_handle; 268 253 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.