Skip to content

Commit

Permalink
small fixes + windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Oct 22, 2024
1 parent 48e7d8e commit 1f5ae4a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
15 changes: 7 additions & 8 deletions ext/iodine/fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3136,7 +3136,7 @@ Memory allocation macros
/** Frees allocated memory. */
#define FIO_MEM_FREE(ptr, size) fio_free((ptr))
/** Set to true of internall allocator is used (memory returned set to zero). */
#define FIO_MEM_REALLOC_IS_SAFE 1
#define FIO_MEM_REALLOC_IS_SAFE fio_realloc_is_safe()

#else /* H___FIO_MALLOC___H */
/** Reallocates memory, copying (at least) `copy_len` if necessary. */
Expand Down Expand Up @@ -10791,12 +10791,12 @@ SFUNC int fio_sock_open2(const char *url, uint16_t flags) {
/** Sets a file descriptor / socket to non blocking state. */
SFUNC int fio_sock_set_non_block(int fd) {
/* If they have O_NONBLOCK, use the Posix way to do it */
#if defined(O_NONBLOCK)
#if defined(O_NONBLOCK) && defined(F_GETFL) && defined(F_SETFL)
/* Fixme: O_NONBLOCK is defined but broken on SunOS 4.1.x and AIX 3.2.5. */
int flags;
if (-1 == (flags = fcntl(fd, F_GETFL, 0)))
flags = 0;
#ifdef O_CLOEXEC
#if defined(O_CLOEXEC)
return fcntl(fd, F_SETFL, flags | O_NONBLOCK | O_CLOEXEC);
#else
return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
Expand Down Expand Up @@ -26479,8 +26479,8 @@ FIO_IFUNC int FIO_NAME(FIO_MAP_NAME,
(FIO_NAME(FIO_MAP_NAME, node_s) *)FIO_MEM_REALLOC_(NULL, 0, s, 0);
if (!n)
return -1;
// if (!FIO_MEM_REALLOC_IS_SAFE_) /* set only imap to zero */
FIO_MEMSET((n + (1ULL << bits)), 0, (1ULL << bits));
if (!FIO_MEM_REALLOC_IS_SAFE_) /* set only imap to zero */
FIO_MEMSET((n + (1ULL << bits)), 0, (1ULL << bits));
*o = (FIO_NAME(FIO_MAP_NAME, s)){.map = n, .bits = bits};
FIO_LEAK_COUNTER_ON_ALLOC(FIO_NAME(FIO_MAP_NAME, destroy));
return 0;
Expand Down Expand Up @@ -27250,7 +27250,7 @@ SFUNC void FIO_NAME(FIO_MAP_NAME, compact)(FIO_MAP_PTR map) {
FIO_NAME(FIO_MAP_NAME, s) *o = FIO_PTR_TAG_GET_UNTAGGED(FIO_MAP_T, map);
if (!o->map || !o->count)
return;
FIO_NAME(FIO_MAP_NAME, s) cpy = {0}, tmp;
FIO_NAME(FIO_MAP_NAME, s) cpy = {0};
uint32_t bits = o->bits;
while (FIO_MAP_CAPA(bits >> 1) > o->count)
bits >>= 1;
Expand All @@ -27268,9 +27268,8 @@ SFUNC void FIO_NAME(FIO_MAP_NAME, compact)(FIO_MAP_PTR map) {
return;

finish:
tmp = o[0];
FIO_NAME(FIO_MAP_NAME, __free_map)(o, 0);
o[0] = cpy;
FIO_NAME(FIO_MAP_NAME, __free_map)(&tmp, 0);
return;
}

Expand Down
4 changes: 4 additions & 0 deletions ext/iodine/iodine_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ static VALUE iodine_cli_parse(VALUE self, VALUE required) {
FIO_STRING_WRITE_STR2(u.query.buf, u.query.len));
fio_cli_set("-b", url.buf);
} else {
#if FIO_OS_WIN
SetEnvironmentVariable("PORT", fio_cli_get("-p"));
#else
setenv("PORT", fio_cli_get("-p"), 1);
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/iodine/iodine_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ static VALUE iodine_handler_deafult_on_http(VALUE handler, VALUE client) {
.copy = 1,
.finish = 1);
} else if (rb_respond_to(bd, IODINE_TO_PATH_ID)) { /* named file body... */
VALUE p = rb_funcall(bd, IODINE_TO_PATH_ID, 0, NULL);
VALUE p = rb_funcallv(bd, IODINE_TO_PATH_ID, 0, NULL);
if (!RB_TYPE_P(p, RUBY_T_STRING))
goto rack_error; /* FIXME? something else? */
if (fio_http_static_file_response(c->http,
Expand Down

0 comments on commit 1f5ae4a

Please sign in to comment.