* Called for each CQE that we receive. Decode the request type that it * came from, and call the appropriate handler. */
| 1898 | * came from, and call the appropriate handler. |
| 1899 | */ |
| 1900 | static int handle_cqe(struct io_uring *ring, struct io_uring_cqe *cqe) |
| 1901 | { |
| 1902 | int ret; |
| 1903 | |
| 1904 | /* |
| 1905 | * Unlikely, but there's an error in this CQE. If an error handler |
| 1906 | * is defined, call it, and that will deal with it. If no error |
| 1907 | * handler is defined, the opcode handler either doesn't care or will |
| 1908 | * handle it on its own. |
| 1909 | */ |
| 1910 | if (cqe->res < 0) { |
| 1911 | struct error_handler *err = &error_handlers[cqe_to_op(cqe)]; |
| 1912 | |
| 1913 | if (err->error_fn) |
| 1914 | return err->error_fn(err, ring, cqe); |
| 1915 | } |
| 1916 | |
| 1917 | switch (cqe_to_op(cqe)) { |
| 1918 | case __ACCEPT: |
| 1919 | ret = handle_accept(ring, cqe); |
| 1920 | break; |
| 1921 | case __SOCK: |
| 1922 | ret = handle_sock(ring, cqe); |
| 1923 | break; |
| 1924 | case __CONNECT: |
| 1925 | ret = handle_connect(ring, cqe); |
| 1926 | break; |
| 1927 | case __RECV: |
| 1928 | case __RECVMSG: |
| 1929 | ret = handle_recv(ring, cqe); |
| 1930 | break; |
| 1931 | case __SEND: |
| 1932 | case __SENDMSG: |
| 1933 | ret = handle_send(ring, cqe); |
| 1934 | break; |
| 1935 | case __CANCEL: |
| 1936 | ret = handle_cancel(ring, cqe); |
| 1937 | break; |
| 1938 | case __SHUTDOWN: |
| 1939 | ret = handle_shutdown(ring, cqe); |
| 1940 | break; |
| 1941 | case __CLOSE: |
| 1942 | ret = handle_close(ring, cqe); |
| 1943 | break; |
| 1944 | case __FD_PASS: |
| 1945 | ret = handle_fd_pass(cqe); |
| 1946 | break; |
| 1947 | case __STOP: |
| 1948 | ret = handle_stop(cqe); |
| 1949 | break; |
| 1950 | case __NOP: |
| 1951 | ret = 0; |
| 1952 | break; |
| 1953 | default: |
| 1954 | fprintf(stderr, "bad user data %lx\n", (long) cqe->user_data); |
| 1955 | return 1; |
| 1956 | } |
| 1957 |
no test coverage detected