Skip to content

Commit

Permalink
HTTP: Move request flags out of exchange + remove ymo_std_http. MISC:…
Browse files Browse the repository at this point in the history
… remove pre-release changelog.
  • Loading branch information
andrew-canaday committed Dec 1, 2021
1 parent d135902 commit 65a5028
Show file tree
Hide file tree
Showing 24 changed files with 107 additions and 101 deletions.
12 changes: 0 additions & 12 deletions CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions benchmarks/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ AM_CFLAGS=\
-I@top_builddir@/include \
-I@top_srcdir@/include \
-I@top_srcdir@/mod/http \
-I@top_srcdir@/mod/http/extra \
-I@top_srcdir@/mod/http/include \
-I@srcdir@

Expand Down
4 changes: 4 additions & 0 deletions benchmarks/benchmark_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "ymo_http_hdr_table.h"
#include "ymo_http.h"
#include "ymo_std_http.h"

/* HACK HACK: so sorry about this. It's temporary. */
#include "ymo_std_http.c"

#include "ymo_benchmark.h"

#define NO_ITERATIONS 10000000
Expand Down
7 changes: 3 additions & 4 deletions include/yimmo.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,11 @@ typedef void (*ymo_user_conn_cleanup_cb_t)(
ymo_conn_t* conn,
void* user);

/** Enumeration type used to pass server configuration flags.
*/
YMO_ENUM16_TYPEDEF(ymo_server_config_flags) {
/** Enumeration type used to pass server configuration flags. */
typedef enum ymo_server_config_flags {
YMO_SERVER_REUSE_ADDR = 0x01, /* allow service to bind while socket in the WAIT state */
YMO_SERVER_REUSE_PORT = 0x02, /* allow multiple processes to bind to the listen port */
} YMO_ENUM16_AS(ymo_server_config_flags_t);
} ymo_server_config_flags_t;

/** Struct used to pass configuration information to
* :c:func:`ymo_server_create`.
Expand Down
85 changes: 53 additions & 32 deletions include/ymo_attrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,76 @@
*---------------------------------------------------------------*/

#if defined(HAVE_VAR_ATTRIBUTE_MODE) && (HAVE_VAR_ATTRIBUTE_MODE == 1)
#define YMO_ATTR_MODE(x) __attribute__((mode(x)))
#define YMO_ENUM8_TYPEDEF(x) typedef enum x
#define YMO_ENUM8_AS(x) x YMO_ATTR_MODE(__byte__)
#define YMO_ENUM16_TYPEDEF(x) enum x
#define YMO_ENUM16_AS(x) ; typedef uint16_t x
// #define YMO_ENUM16_TYPEDEF(x) typedef enum x
// #define YMO_ENUM16_AS(x) x YMO_ATTR_MODE(HImode)
# define YMO_ATTR_MODE(x) __attribute__((mode(x)))
#else
#define YMO_ATTR_MODE(x)
#define YMO_ENUM8_TYPEDEF(x) enum x
#define YMO_ENUM8_AS(x) ; typedef uint8_t x
#define YMO_ENUM16_TYPEDEF(x) enum x
#define YMO_ENUM16_AS(x) ; typedef uint16_t x
# define YMO_ATTR_MODE(x)
#endif /* HAVE_VAR_ATTRIBUTE_MODE */

#if defined(HAVE_VAR_ATTRIBUTE_ALIGNED) && (HAVE_VAR_ATTRIBUTE_ALIGNED == 1)
#define YMO_ATTR_ALIGNED(x) __attribute__((aligned(x)))
# define YMO_ATTR_ALIGNED(x) __attribute__((aligned(x)))
#else
#define YMO_ATTR_ALIGNED(x)
# define YMO_ATTR_ALIGNED(x)
#endif /* HAVE_VAR_ATTRIBUTE_ALIGNED */


/*---------------------------------------------------------------*
* Packed Enum Definitions:
* (To disable #define YMO_ENUM_NO_PACK 1)
*---------------------------------------------------------------*/

#if defined(YMO_ENUM_NO_PACK) && (YMO_ENUM_NO_PACK == 1)
# define YMO_ENUM8_TYPEDEF(x) typedef enum x
# define YMO_ENUM8_AS(x) x
# define YMO_ENUM16_TYPEDEF(x) typedef enum x
# define YMO_ENUM16_AS(x) x
#else
# if defined(HAVE_VAR_ATTRIBUTE_MODE) && (HAVE_VAR_ATTRIBUTE_MODE == 1)
# define YMO_ENUM8_TYPEDEF(x) typedef enum x
# define YMO_ENUM8_AS(x) x YMO_ATTR_MODE(__byte__)
# define YMO_ENUM16_TYPEDEF(x) enum x
# define YMO_ENUM16_AS(x) ; typedef uint16_t x
/* TODO: why did I do this? Also, why did I undo it? */
# if 0
# define YMO_ENUM16_TYPEDEF(x) typedef enum x
# define YMO_ENUM16_AS(x) x YMO_ATTR_MODE(HImode)
# endif
# else
# define YMO_ENUM8_TYPEDEF(x) enum x
# define YMO_ENUM8_AS(x) ; typedef uint8_t x
# define YMO_ENUM16_TYPEDEF(x) enum x
# define YMO_ENUM16_AS(x) ; typedef uint16_t x
# endif /* HAVE_VAR_ATTRIBUTE_MODE */
#endif /* YMO_ENUM_NO_PACK */


/*---------------------------------------------------------------*
* Compiler Function Attribute Wrappers:
*---------------------------------------------------------------*/

#if defined(HAVE_FUNC_ATTRIBUTE_MALLOC) && (HAVE_FUNC_ATTRIBUTE_MALLOC == 1)
# define YMO_FUNC_MALLOC __attribute__((malloc))
# define YMO_FUNC_MALLOC_A malloc
# define YMO_FUNC_MALLOC_P malloc,
# define YMO_FUNC_MALLOC __attribute__((malloc))
# define YMO_FUNC_MALLOC_A malloc
# define YMO_FUNC_MALLOC_P malloc,
#else
# define YMO_FUNC_MALLOC
# define YMO_FUNC_MALLOC_A
# define YMO_FUNC_MALLOC_P
#endif /* HAVE_FUNC_ATTRIBUTE_MALLOC */

#if defined(HAVE_FUNC_ATTRIBUTE_UNUSED) && (HAVE_FUNC_ATTRIBUTE_UNUSED == 1)
# define YMO_FUNC_UNUSED __attribute__((unused))
# define YMO_FUNC_UNUSED_A unused
# define YMO_FUNC_UNUSED_P unused,
# define YMO_FUNC_UNUSED __attribute__((unused))
# define YMO_FUNC_UNUSED_A unused
# define YMO_FUNC_UNUSED_P unused,
#else
# define YMO_FUNC_UNUSED
# define YMO_FUNC_UNUSED_A
# define YMO_FUNC_UNUSED_P
#endif /* HAVE_FUNC_ATTRIBUTE_UNUSED */

#if defined(HAVE_FUNC_ATTRIBUTE_FLATTEN) && (HAVE_FUNC_ATTRIBUTE_FLATTEN == 1)
# define YMO_FUNC_FLATTEN __attribute__((flatten))
# define YMO_FUNC_FLATTEN_A flatten
# define YMO_FUNC_FLATTEN_P flatten,
# define YMO_FUNC_FLATTEN __attribute__((flatten))
# define YMO_FUNC_FLATTEN_A flatten
# define YMO_FUNC_FLATTEN_P flatten,
#else
# define YMO_FUNC_FLATTEN
# define YMO_FUNC_FLATTEN_A
Expand All @@ -110,29 +131,29 @@
#endif /* HAVE_FUNC_ATTRIBUTE_FALLTHROUGH */

#if defined(HAVE_FUNC_ATTRIBUTE_WEAK) && (HAVE_FUNC_ATTRIBUTE_WEAK == 1)
# define YMO_FUNC_WEAK __attribute__((weak))
# define YMO_FUNC_WEAK_A weak
# define YMO_FUNC_WEAK_P weak,
# define YMO_FUNC_WEAK __attribute__((weak))
# define YMO_FUNC_WEAK_A weak
# define YMO_FUNC_WEAK_P weak,
#else
# define YMO_FUNC_WEAK
# define YMO_FUNC_WEAK_A
# define YMO_FUNC_WEAK_P
#endif /* HAVE_FUNC_ATTRIBUTE_WEAK */

#if defined(HAVE_FUNC_ATTRIBUTE_WEAKREF) && (HAVE_FUNC_ATTRIBUTE_WEAKREF == 1)
# define YMO_FUNC_WEAKREF(x) __attribute__((weakref(#x)))
# define YMO_FUNC_WEAKREF_A(x) weakref(#x)
# define YMO_FUNC_WEAKREF_P(x) weakref(#x),
# define YMO_FUNC_WEAKREF(x) __attribute__((weakref(#x)))
# define YMO_FUNC_WEAKREF_A(x) weakref(#x)
# define YMO_FUNC_WEAKREF_P(x) weakref(#x),
#else
# define YMO_FUNC_WEAKREF
# define YMO_FUNC_WEAKREF_A
# define YMO_FUNC_WEAKREF_P
#endif /* HAVE_FUNC_ATTRIBUTE_WEAKREF */

#if defined(HAVE_FUNC_ATTRIBUTE_ALIAS) && (HAVE_FUNC_ATTRIBUTE_ALIAS == 1)
# define YMO_FUNC_ALIAS(x) __attribute__((alias(#x)))
# define YMO_FUNC_ALIAS_A(x) alias(#x)
# define YMO_FUNC_ALIAS_P(x) alias(#x),
# define YMO_FUNC_ALIAS(x) __attribute__((alias(#x)))
# define YMO_FUNC_ALIAS_A(x) alias(#x)
# define YMO_FUNC_ALIAS_P(x) alias(#x),
#else
# define YMO_FUNC_ALIAS
# define YMO_FUNC_ALIAS_A
Expand Down
6 changes: 3 additions & 3 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ lib_LTLIBRARIES=\
libyimmo.la

libyimmo_la_CFLAGS=\
-I@top_builddir@/include \
-I@top_srcdir@/include \
-I@top_srcdir@/lib \
-I@top_builddir@/include \
-I@top_srcdir@/include \
-I@top_srcdir@/lib \
@BSAT_CFLAGS@

libyimmo_la_LDFLAGS=\
Expand Down
12 changes: 6 additions & 6 deletions lib/test/test_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ static int add_headers(void)
r_val = ymo_trie_add_string(trie, hdr);
ymo_assert(r_val == YMO_OKAY);
}
YMO_TAP_PASS("TODO: update message");
YMO_TAP_PASS(__func__);
}

static int create_oitrie(void)
{
oitrie = ymo_oitrie_create(trie);
ymo_assert(oitrie != NULL);
YMO_TAP_PASS("TODO: update message");
YMO_TAP_PASS(__func__);
}

static int check_headers(void)
Expand All @@ -108,7 +108,7 @@ static int check_headers(void)
r_val = ymo_oitrie_get_id(&hdr_id, oitrie, hdr);
ymo_assert(r_val == YMO_OKAY);
}
YMO_TAP_PASS("TODO: update message");
YMO_TAP_PASS(__func__);
}

static int check_missing(void)
Expand All @@ -117,7 +117,7 @@ static int check_missing(void)
hdr = "Not-A-Real-Header";
r_val = ymo_oitrie_get_id(&hdr_id, oitrie, hdr);
ymo_assert(r_val == EINVAL);
YMO_TAP_PASS("TODO: update message");
YMO_TAP_PASS(__func__);
}

static int check_partial1(void)
Expand All @@ -126,7 +126,7 @@ static int check_partial1(void)
hdr = "Accept-Charse";
r_val = ymo_oitrie_get_id(&hdr_id, oitrie, hdr);
ymo_assert(r_val == EINVAL);
YMO_TAP_PASS("TODO: update message");
YMO_TAP_PASS(__func__);
}

static int check_partial2(void)
Expand All @@ -135,7 +135,7 @@ static int check_partial2(void)
hdr = "Accept-Charset-";
r_val = ymo_oitrie_get_id(&hdr_id, oitrie, hdr);
ymo_assert(r_val == EINVAL);
YMO_TAP_PASS("TODO: update message");
YMO_TAP_PASS(__func__);
}

/*-------------------------------------------------------------*
Expand Down
2 changes: 1 addition & 1 deletion lib/ymo_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
*/
#define ymo_assert_test_pass_fmt(fmt, ...) \
if( YMO_ASSERT_VERBOSE ) { \
fprintf(YMO_ASSERT_STREAM_OUT, \
fprintf(YMO_ASSERT_STREAM_OUT, \
" - \033[00;32mPASS: "fmt " (%s:%s:%i)\033[00;m\n", \
__VA_ARGS__, YMO_SOURCE, __func__, __LINE__); \
}
Expand Down
1 change: 0 additions & 1 deletion lib/ymo_bucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ YMO_ENUM8_TYPEDEF(ymo_bucket_code) {
*---------------------------------------------------------------*/

/* TODO: this should probably take the bucket data, as well...
* TODO: this isn't used...
*/
typedef ymo_status_t (*ymo_bucket_cb_t)(void* data);

Expand Down
2 changes: 2 additions & 0 deletions lib/ymo_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ struct ymo_conn {
int ev_flags; /* Used to store EV_READ/EV_WRITE flags */
struct ev_io w_read; /* Per-connection read watcher */
struct ev_io w_write; /* Per-connection write watcher */
#if defined(YMO_CONN_LOCK) && (YMO_CONN_LOCK == 1)
pthread_mutexattr_t lattr; /* Per-connection mutex attributes */
pthread_mutex_t lock; /* Per-connection mutex */
#endif /* YMO_CONN_LOCK */
};

/*---------------------------------------------------------------*
Expand Down
1 change: 1 addition & 0 deletions lib/ymo_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <string.h>
#include <signal.h>
#include <sys/mman.h>
#include <stdatomic.h>

#include "yimmo.h"
#include "ymo_alloc.h"
Expand Down
3 changes: 0 additions & 3 deletions lib/ymo_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@
#include <bsat.h>

#include "yimmo.h"
#include "ymo_proto.h"
#include "ymo_trie.h"

#include "ymo_proto.h"

/**---------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions lib/ymo_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ char ymo_toupper(char c)
#endif /* YMO_TOLOWER_NO_INLINE */


/* TODO: SIMD optimizations here? */
void ymo_ntolower(char* dst, const char* src, size_t len)
{
/* Number of iterations we can perform at maximum stride: */
Expand Down Expand Up @@ -204,7 +203,6 @@ void ymo_ntolower(char* dst, const char* src, size_t len)
}


/* TODO: SIMD optimizations here? */
void ymo_ntoupper(char* dst, const char* src, size_t len)
{
/* Number of iterations we can perform at maximum stride: */
Expand Down
1 change: 0 additions & 1 deletion mod/http/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ libyimmo_http_la_LDFLAGS=\
@BSAT_LIBS@

libyimmo_http_la_SOURCES=\
ymo_std_http.c \
ymo_proto_http.c \
ymo_http_session.c \
ymo_http_parse.c \
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions mod/http/include/ymo_http.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ struct ymo_http_request {
char* body; /* Optionally buffered body data */
size_t body_received; /* Body data received */
size_t content_length; /* Content-length, per client */
ymo_http_flags_t flags; /* Request flags */
};

/** Responses
Expand Down
14 changes: 9 additions & 5 deletions mod/http/test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
@top_srcdir@/build-aux/tap-driver.sh

AM_CFLAGS=\
-I@top_builddir@/include \
-I@top_srcdir@/include \
-I@top_srcdir@/lib \
-I@top_srcdir@/mod \
-I@top_builddir@/include \
-I@top_srcdir@/include \
-I@top_srcdir@/lib \
-I@top_srcdir@/mod \
-I@top_srcdir@/mod/http \
-I@top_srcdir@/mod/http/include \
-I@top_srcdir@/mod/http/include \
@BSAT_CFLAGS@

AM_LDFLAGS=\
@BSAT_LIBS@ \
@LIBS@

LDADD=\
$(top_builddir)/mod/http/libyimmo_http.la \
$(top_builddir)/lib/libyimmo.la
Expand Down
4 changes: 2 additions & 2 deletions mod/http/ymo_http_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void ymo_http_exchange_reset(ymo_http_exchange_t* exchange)
exchange->request.content_length = 0;
exchange->request.body_received = 0;
exchange->recv_current = exchange->recv_buf;
exchange->flags = 0;
exchange->request.flags = 0;
exchange->state = HTTP_STATE_CONNECTED;
exchange->next_state = 0;
exchange->remain = YMO_HTTP_RECV_BUF_SIZE;
Expand All @@ -90,7 +90,7 @@ void ymo_http_exchange_reset(ymo_http_exchange_t* exchange)

ymo_http_flags_t ymo_http_request_flags(const ymo_http_exchange_t* exchange)
{
return exchange->flags;
return exchange->request.flags;
}

void ymo_http_exchange_free(ymo_http_exchange_t* exchange)
Expand Down
5 changes: 0 additions & 5 deletions mod/http/ymo_http_exchange.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ YMO_ENUM8_TYPEDEF(crlf_state) {
HTTP_EXPECT_LF,
} YMO_ENUM8_AS(crlf_state_t);

/** Indicates the offset for a given HTTP header value within recv_buf.
*/
typedef uint16_t ymo_http_hdr_offset_t;

/** Struct used to store HTTP exchange data.
*
* .. TODO::
Expand All @@ -94,7 +90,6 @@ struct ymo_http_exchange {
};
};

ymo_http_flags_t flags;
http_state_t state;
http_state_t next_state;
char* recv_current;
Expand Down
Loading

0 comments on commit 65a5028

Please sign in to comment.