Skip to content

Commit

Permalink
more cleanup and joy
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Oct 22, 2024
1 parent 0038f6b commit 24dee0f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
- name: Install Gems
run: bundle install
- name: Build and Test Iodine
- name: Compile and Install Iodine
run: |
echo CFLAGS = $CFLAGS
echo cflags = $cflags
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
- name: Install Gems
run: bundle install
- name: Build and Test Iodine
- name: Compile Iodine
run: |
echo CFLAGS = $CFLAGS
echo cflags = $cflags
Expand Down
6 changes: 2 additions & 4 deletions ext/iodine/fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40825,9 +40825,7 @@ static int fio_http1___start(fio_http1_parser_s *p,
eol -= eol[-1] == '\r';

/* parse first line */
if (start[0] > ('0' - 1) && start[0] < ('9' + 1))
goto parse_response_line;
/* request: method path version */
/* request: method path version ; response: version code txt */
if (!(tmp = (char *)FIO_MEMCHR(start, ' ', (size_t)(eol - start))))
return -1;
wrd[0] = FIO_BUF_INFO2(start, (size_t)(tmp - start));
Expand All @@ -40839,7 +40837,7 @@ static int fio_http1___start(fio_http1_parser_s *p,
if (start >= eol)
return -1;
wrd[2] = FIO_BUF_INFO2(start, (size_t)(eol - start));
if (fio_c2i(wrd[1].buf[0]) < 10)
if (fio_c2i(wrd[1].buf[0]) < 10) /* test if path or code */
goto parse_response_line;
if (wrd[2].len > 14)
wrd[2].len = 14;
Expand Down
14 changes: 7 additions & 7 deletions ext/iodine/iodine_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ FIO_SFUNC VALUE iodine_connection_body_seek(int argc, VALUE *argv, VALUE o) {
iodine_connection_s *c = iodine_connection_ptr(o);
if (!c->http)
return Qnil;
long long pos = 0;
int64_t pos = 0;
iodine_rb2c_arg(argc, argv, IODINE_ARG_NUM(pos, 0, "pos", 0));
pos = (long long)fio_http_body_seek(c->http, (ssize_t)pos);
return ULL2NUM(pos);
Expand Down Expand Up @@ -1719,7 +1719,7 @@ FIO_IFUNC VALUE iodine_connection_subscribe_internal(fio_s *io,
int argc,
VALUE *argv) {
fio_buf_info_s channel = FIO_BUF_INFO2(NULL, 0);
long long filter = 0;
int64_t filter = 0;
VALUE proc = Qnil;

iodine_rb2c_arg(argc,
Expand Down Expand Up @@ -1748,7 +1748,7 @@ FIO_IFUNC VALUE iodine_connection_subscribe_internal(fio_s *io,
static VALUE iodine_connection_unsubscribe_internal(fio_s *io,
int argc,
VALUE *argv) {
long long filter = 0;
int64_t filter = 0;
fio_buf_info_s channel = FIO_BUF_INFO2(NULL, 0);
iodine_rb2c_arg(argc,
argv,
Expand Down Expand Up @@ -1805,12 +1805,12 @@ FIO_IFUNC iodine_connection_args_s iodine_connection_parse_args(int argc,
.log = fio_cli_get_bool("-v"),
},
};
VALUE proc = Qnil;
VALUE proc = Qnil, handler_tmp = Qnil;
iodine_rb2c_arg(
argc,
argv,
IODINE_ARG_BUF(r.url, 0, "url", 0),
IODINE_ARG_RB((((VALUE *)&r.settings.udata)[0]), 0, "handler", 0),
IODINE_ARG_RB(handler_tmp, 0, "handler", 0),
IODINE_ARG_BUF(r.hint, 0, "service", 0),
IODINE_ARG_RB(r.rb_tls, 0, "tls", 0),
IODINE_ARG_STR(r.settings.public_folder, 0, "public", 0),
Expand All @@ -1827,7 +1827,7 @@ FIO_IFUNC iodine_connection_args_s iodine_connection_parse_args(int argc,
IODINE_ARG_BUF(r.body, 0, "body", 0),
IODINE_ARG_RB(r.cookies, 0, "cookies", 0),
IODINE_ARG_PROC(proc, 0, "block", 0));

r.settings.udata = (void *)handler_tmp;
/* test for errors before allocating or protecting data */

if (r.headers != Qnil && !RB_TYPE_P(r.headers, RUBY_T_HASH))
Expand Down Expand Up @@ -2408,7 +2408,7 @@ static VALUE iodine_connection_publish_internal(fio_s *io,
VALUE self) {
VALUE message = Qnil;
VALUE engine = Qnil;
long long filter = 0;
int64_t filter = 0;
fio_buf_info_s channel = FIO_BUF_INFO2(NULL, 0);
fio_buf_info_s msg = FIO_BUF_INFO2(NULL, 0);
char *to_free = NULL;
Expand Down
2 changes: 1 addition & 1 deletion ext/iodine/iodine_minimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static _Bool iodinde_hmap_object_cmp(VALUE a, VALUE b) {
#define FIO_MAP_KEY VALUE
#define FIO_MAP_VALUE VALUE
#define FIO_MAP_HASH_FN iodinde_hmap_hash
#define FIO_MAP_KEY_CMP(a, b) iodinde_hmap_object_cmp
#define FIO_MAP_KEY_CMP(a, b) iodinde_hmap_object_cmp(a, b)
#define FIO_MAP_KEY_COPY(dest, src) ((dest) = (src))
#include FIO_INCLUDE_FILE

Expand Down
20 changes: 0 additions & 20 deletions ext/iodine/iodine_pubsub_eng.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,10 @@
Ruby PubSub Engine Type
***************************************************************************** */

typedef enum {
// IODINE_PUBSUB_ENG_STORE_handler,
// IODINE_PUBSUB_ENG_STORE_channel,
// IODINE_PUBSUB_ENG_STORE_filter,
// IODINE_PUBSUB_ENG_STORE_engine,
// IODINE_PUBSUB_ENG_STORE_published,
IODINE_PUBSUB_ENG_STORE_FINISH,
} iodine_pubsub_eng_store_e;

typedef struct iodine_pubsub_eng_s {
fio_pubsub_engine_s engine;
fio_pubsub_engine_s *ptr;
VALUE handler;
VALUE store[IODINE_PUBSUB_ENG_STORE_FINISH];
} iodine_pubsub_eng_s;

/* *****************************************************************************
Expand Down Expand Up @@ -180,13 +170,6 @@ static size_t iodine_pubsub_eng_data_size(const void *ptr_) {
return sizeof(*m);
}

static void iodine_pubsub_eng_mark(void *m_) {
iodine_pubsub_eng_s *m = (iodine_pubsub_eng_s *)m_;
for (size_t i = 0; i < IODINE_PUBSUB_ENG_STORE_FINISH; ++i)
if (!IODINE_STORE_IS_SKIP(m->store[i]))
rb_gc_mark(m->store[i]);
}

static void iodine_pubsub_eng_free(void *ptr_) {
iodine_pubsub_eng_s *e = (iodine_pubsub_eng_s *)ptr_;
if (FIO_PUBSUB_DEFAULT == e->ptr)
Expand All @@ -199,7 +182,6 @@ static const rb_data_type_t IODINE_PUBSUB_ENG_DATA_TYPE = {
.wrap_struct_name = "IodinePSEngine",
.function =
{
.dmark = iodine_pubsub_eng_mark,
.dfree = iodine_pubsub_eng_free,
.dsize = iodine_pubsub_eng_data_size,
},
Expand All @@ -213,8 +195,6 @@ static VALUE iodine_pubsub_eng_alloc(VALUE klass) {
goto no_memory;
*m = (iodine_pubsub_eng_s){0};
m->ptr = &m->engine;
for (size_t i = 0; i < IODINE_PUBSUB_ENG_STORE_FINISH; ++i)
m->store[i] = Qnil;
FIO_LEAK_COUNTER_ON_ALLOC(iodine_pubsub_eng);
m->handler = TypedData_Wrap_Struct(klass, &IODINE_PUBSUB_ENG_DATA_TYPE, m);
m->engine = iodine_pubsub___engine_validate(m->handler);
Expand Down
2 changes: 1 addition & 1 deletion ext/iodine/iodine_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Time to String Helpers

FIO_IFUNC time_t iodine_utils_rb2time(VALUE rtm) {
rtm = rb_funcallv(rtm, rb_intern("to_i"), 0, NULL);
return FIX2ULONG(rtm) ? FIX2ULONG(rtm) : fio_time_real().tv_sec;
return FIX2LONG(rtm) ? FIX2LONG(rtm) : fio_time_real().tv_sec;
}

/** Takes a Time object and returns a String conforming to RFC 2109. */
Expand Down

0 comments on commit 24dee0f

Please sign in to comment.