1.1 --- a/libfsclient/lib/src/process.cc Sat Dec 09 01:26:55 2023 +0100
1.2 +++ b/libfsclient/lib/src/process.cc Sat Dec 09 01:27:19 2023 +0100
1.3 @@ -36,11 +36,11 @@
1.4
1.5 /* Utility functions. */
1.6
1.7 -static bool _process_terminated(process_t *process)
1.8 +static bool _process_terminated(notifiable_t *notifiable)
1.9 {
1.10 - return ((process->notifiable.notifications & NOTIFY_TASK_SIGNAL) &&
1.11 - (process->notifiable.values.sig == 0)) ||
1.12 - (process->notifiable.notifications & NOTIFY_TASK_ERROR);
1.13 + return ((notifiable->notifications & NOTIFY_TASK_SIGNAL) &&
1.14 + (notifiable->values.sig == 0)) ||
1.15 + (notifiable->notifications & NOTIFY_TASK_ERROR);
1.16 }
1.17
1.18
1.19 @@ -146,106 +146,54 @@
1.20
1.21
1.22
1.23 -/* NOTE: Much of the code below could be unified with the file-related
1.24 - notification code. */
1.25 -
1.26 -/* Opaque notifier type for process_notifier_t. */
1.27 -
1.28 -struct process_notifier
1.29 -{
1.30 - ObjectNotifier *obj;
1.31 -};
1.32 -
1.33 /* Conversion to the generic notification types. */
1.34
1.35 notifiable_t *process_notifiable(process_t *process)
1.36 {
1.37 - return &process->notifiable;
1.38 + return notify_notifiable((notifiable_base_t *) process);
1.39 }
1.40
1.41 /* Return the notification flags for a process. */
1.42
1.43 notify_flags_t process_notifications(process_t *process)
1.44 {
1.45 - return process->notifiable.notifications;
1.46 + return notify_notifications((notifiable_base_t *) process);
1.47 }
1.48
1.49 /* Return the notification values for a process. */
1.50
1.51 notify_values_t process_notification_values(process_t *process)
1.52 {
1.53 - return process->notifiable.values;
1.54 -}
1.55 -
1.56 -/* Close a notifier object. */
1.57 -
1.58 -void process_notify_close(process_notifier_t *notifier)
1.59 -{
1.60 - delete notifier->obj;
1.61 - delete notifier;
1.62 -}
1.63 -
1.64 -/* Obtain a local notifier object. */
1.65 -
1.66 -process_notifier_t *process_notify_local()
1.67 -{
1.68 - process_notifier_t *notifier = new process_notifier_t;
1.69 -
1.70 - notifier->obj = notifier_get_local_notifier();
1.71 - return notifier;
1.72 -}
1.73 -
1.74 -/* Obtain the task-wide notifier object. */
1.75 -
1.76 -process_notifier_t *process_notify_task()
1.77 -{
1.78 - process_notifier_t *notifier = new process_notifier_t;
1.79 -
1.80 - notifier->obj = notifier_get_task_notifier();
1.81 - return notifier;
1.82 -}
1.83 -
1.84 -/* Subscribe to notification events on a process. */
1.85 -
1.86 -long process_notify_subscribe(process_t *process, notify_flags_t flags, process_notifier_t *notifier)
1.87 -{
1.88 - return notifier->obj->subscribe(process_notifiable(process), flags);
1.89 -}
1.90 -
1.91 -/* Unsubscribe from notification events on a process. */
1.92 -
1.93 -long process_notify_unsubscribe(process_t *process, process_notifier_t *notifier)
1.94 -{
1.95 - return notifier->obj->unsubscribe(process_notifiable(process));
1.96 + return notify_notification_values((notifiable_base_t *) process);
1.97 }
1.98
1.99 /* Wait for a notification event on a process. */
1.100
1.101 -long process_notify_wait_process(process_t *process, process_notifier_t *notifier)
1.102 +long process_notify_wait_process(process_t *process, notifier_t *notifier)
1.103 {
1.104 - long err = notifier->obj->wait_object(process_notifiable(process));
1.105 + long err = notify_wait(process_notifiable(process), notifier);
1.106
1.107 /* Unsubscribe if a termination notification has been received. */
1.108
1.109 - if (!err && _process_terminated(process))
1.110 - process_notify_unsubscribe(process, notifier);
1.111 + if (!err && _process_terminated(process_notifiable(process)))
1.112 + notify_unsubscribe(process_notifiable(process), notifier);
1.113
1.114 return err;
1.115 }
1.116
1.117 /* Wait for notification events on processes. */
1.118
1.119 -long process_notify_wait_processes(process_t **process, process_notifier_t *notifier)
1.120 +long process_notify_wait_processes(process_t **process, notifier_t *notifier)
1.121 {
1.122 notifiable_t *notifiable;
1.123 - long err = notifier->obj->wait(¬ifiable);
1.124 + long err = notify_wait_many(¬ifiable, notifier);
1.125
1.126 *process = (process_t *) notifiable->base;
1.127
1.128 /* Unsubscribe if a termination notification has been received. */
1.129
1.130 - if (!err && _process_terminated(*process))
1.131 - process_notify_unsubscribe(*process, notifier);
1.132 + if (!err && _process_terminated(notifiable))
1.133 + notify_unsubscribe(notifiable, notifier);
1.134
1.135 return err;
1.136 }