| 107 | }; |
| 108 | |
| 109 | static struct dm_cond *dm_get_cond(int type, diameter_reply_cb *cb, void *param) |
| 110 | { |
| 111 | struct dm_cond *cond = shm_malloc(sizeof *cond); |
| 112 | if (!cond) { |
| 113 | LM_ERR("oom\n"); |
| 114 | return NULL; |
| 115 | } |
| 116 | memset(cond, 0, sizeof *cond); |
| 117 | cond->ref = 1; |
| 118 | cond->type = type; |
| 119 | switch (type) { |
| 120 | case DM_TYPE_EVENT: |
| 121 | cond->sync.event.pid = process_no; |
| 122 | cond->sync.event.fd = eventfd(0, 0); |
| 123 | if (cond->sync.event.fd < 0) { |
| 124 | LM_ERR("could not create event fd\n"); |
| 125 | shm_free(cond); |
| 126 | return NULL; |
| 127 | } |
| 128 | break; |
| 129 | case DM_TYPE_COND: |
| 130 | init_mutex_cond(&cond->sync.cond.mutex, &cond->sync.cond.cond); |
| 131 | break; |
| 132 | case DM_TYPE_CB: |
| 133 | if (!cb) |
| 134 | LM_WARN("no callback specified\n"); |
| 135 | cond->sync.cb.f = cb; |
| 136 | cond->sync.cb.p = param; |
| 137 | break; |
| 138 | } |
| 139 | |
| 140 | return cond; |
| 141 | } |
| 142 | |
| 143 | int dm_init_reply_cond(int proc_rank) |
| 144 | { |
no test coverage detected