| 219 | } |
| 220 | |
| 221 | static void completion(struct ctx *ctx, struct io_uring_cqe *cqe) |
| 222 | { |
| 223 | char type; |
| 224 | int fd; |
| 225 | int res = cqe->res; |
| 226 | |
| 227 | decodeUserData(cqe->user_data, &type, &fd); |
| 228 | if (res < 0) { |
| 229 | fprintf(stderr, "unexpected %s failure: (%d) %s\n", |
| 230 | opTypeToStr(type), -res, strerror(-res)); |
| 231 | abort(); |
| 232 | } |
| 233 | |
| 234 | switch (type) { |
| 235 | case IOURING_SENDMSG: |
| 236 | receivePing(ctx); |
| 237 | --ctx->num_pings; |
| 238 | break; |
| 239 | case IOURING_RECVMSG: |
| 240 | ctx->iov.iov_len = res; |
| 241 | sendPing(ctx); |
| 242 | if (!ctx->napi_check) |
| 243 | reportNapi(ctx); |
| 244 | break; |
| 245 | default: |
| 246 | fprintf(stderr, "unexpected %s completion\n", |
| 247 | opTypeToStr(type)); |
| 248 | abort(); |
| 249 | break; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | int main(int argc, char *argv[]) |
| 254 | { |
no test coverage detected