123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #if 0
- /* shttpd http - react to readyness and completeness
- Copyright (C) 2018 Ariadne Devos
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
- #include <sHT/intrisics.h>
- #include "worker.h"
- #include <errno.h>
- #include <stddef.h>
- #include <sys/epoll.h>
- #include <sys/socket.h>
- __attribute__((nonnull (1, 2)))
- static void
- sHT_other_task(struct sHT_worker *worker, struct sHT_task *task)
- {
- sHT_assert(0);
- }
- __attribute__((nonnull (1, 2)))
- static void
- sHT_aio_task(struct sHT_worker *worker, struct sHT_task *task)
- {
- sHT_assert(0);
- }
- void
- sHT_sendstatus_task(struct sHT_worker *worker, struct sHT_task *task)
- {
- sHT_assert(0);
- }
- /* The idea of calling read, write, recv, send, accept ... ourselves is that
- the worker's variable code (i.e. specialised code for TLS, HTTP, a prime
- sieve ...) is somewhat independent of the socket interfaces of the kernel.
- The worker can, however, still do this by itself using sHT_TASK_NOTHING.
- TODO: This allows us to treat intra-machine communication specially, e.g.
- with shared memory. (Note: this would require memory_order_relaxed or
- volatile.)
- */
- void
- sHT_perform_task(struct sHT_worker *worker, struct sHT_task *task)
- {
- /* The C compiler probably knows better than me how this should be
- compiled (e.g. with a jump table). */
- switch((enum sHT_task_type) (task->flags & sHT_TASK_TYPE_MASK)) {
- case sHT_TASK_T_DIY:
- sHT_other_task(worker, task);
- break;
- case sHT_TASK_T_SOCKET_STREAM:
- sHT_socket_task(worker, task);
- break;
- case sHT_TASK_T_ASYNC_IO:
- sHT_aio_task(worker, task);
- break;
- case sHT_TASK_T_ACCEPT:
- sHT_accept_task(worker, task);
- break;
- case sHT_TASK_T_SENDSTATUS:
- sHT_sendstatus_task(worker, task);
- break;
- default:
- sHT_assert(0 && task->flags);
- }
- }
- #endif
|