Skip to content

Commit 74786af

Browse files
bugfix: windows does not support ngx_http_lua_ffi_worker_pids.
1 parent ce30e2f commit 74786af

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ before_install:
6565
- '! grep -n -P ''(?<=.{80}).+'' --color `find src -name ''*.c''` `find . -name ''*.h''` || (echo "ERROR: Found C source lines exceeding 80 columns." > /dev/stderr; exit 1)'
6666
- '! grep -n -P ''\t+'' --color `find src -name ''*.c''` `find . -name ''*.h''` || (echo "ERROR: Cannot use tabs." > /dev/stderr; exit 1)'
6767
- /usr/bin/env perl $(command -v cpanm) --sudo --notest Test::Nginx IPC::Run > build.log 2>&1 || (cat build.log && exit 1)
68+
- pyenv global 2.7
6869
install:
6970
- if [ ! -f download-cache/drizzle7-$DRIZZLE_VER.tar.gz ]; then wget -P download-cache http://openresty.org/download/drizzle7-$DRIZZLE_VER.tar.gz; fi
7071
- if [ ! -f download-cache/pcre-$PCRE_VER.tar.gz ]; then wget -P download-cache https://downloads.sourceforge.net/project/pcre/pcre/${PCRE_VER}/pcre-${PCRE_VER}.tar.gz; fi

src/ngx_http_lua_socket_tcp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6483,7 +6483,7 @@ ngx_http_lua_ffi_socket_tcp_getoption(ngx_http_lua_socket_tcp_upstream_t *u,
64836483

64846484
fd = u->peer.connection->fd;
64856485

6486-
if (fd == (ngx_socket_t) -1) {
6486+
if (fd == (int) -1) {
64876487
*errlen = ngx_snprintf(err, *errlen, "invalid socket fd") - err;
64886488
return NGX_ERROR;
64896489
}
@@ -6540,7 +6540,7 @@ ngx_http_lua_ffi_socket_tcp_setoption(ngx_http_lua_socket_tcp_upstream_t *u,
65406540

65416541
fd = u->peer.connection->fd;
65426542

6543-
if (fd == (ngx_socket_t) -1) {
6543+
if (fd == (int) -1) {
65446544
*errlen = ngx_snprintf(err, *errlen, "invalid socket fd") - err;
65456545
return NGX_ERROR;
65466546
}
@@ -6601,7 +6601,7 @@ ngx_http_lua_ffi_socket_tcp_hack_fd(ngx_http_lua_socket_tcp_upstream_t *u,
66016601
}
66026602

66036603
rc = u->peer.connection->fd;
6604-
if (rc == (ngx_socket_t) -1) {
6604+
if (rc == (int) -1) {
66056605
*errlen = ngx_snprintf(err, *errlen, "invalid socket fd") - err;
66066606
return -1;
66076607
}

src/ngx_http_lua_worker.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
#define DDEBUG 0
99
#endif
1010
#include "ddebug.h"
11+
12+
#if !(NGX_WIN32)
1113
#include <ngx_channel.h>
14+
#endif
1215

1316

1417
#define NGX_PROCESS_PRIVILEGED_AGENT 99
@@ -21,13 +24,15 @@ ngx_http_lua_ffi_worker_pid(void)
2124
}
2225

2326

27+
#if !(NGX_WIN32)
2428
int
2529
ngx_http_lua_ffi_worker_pids(int *pids, size_t *pids_len)
2630
{
27-
ngx_int_t i, n;
31+
size_t n;
32+
ngx_int_t i;
2833

2934
n = 0;
30-
for (i = 0; i < NGX_MAX_PROCESSES; i++) {
35+
for (i = 0; n < *pids_len && i < NGX_MAX_PROCESSES; i++) {
3136
if (i != ngx_process_slot && ngx_processes[i].pid == 0) {
3237
break;
3338
}
@@ -49,6 +54,7 @@ ngx_http_lua_ffi_worker_pids(int *pids, size_t *pids_len)
4954

5055
return NGX_OK;
5156
}
57+
#endif
5258

5359

5460
int

0 commit comments

Comments
 (0)