<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello all,<div class=""><br class=""></div><div class="">I’m trying to build a nginx module both with C code and Go code. The idea is to create a Go code that is compiled into a shared library and then call function of this lib from a basic nginx module C code.</div><div class=""><br class=""></div><div class="">Here is my handler (in C), taken from this guide: <a href="https://www.airpair.com/nginx/extending-nginx-tutorial" class="">https://www.airpair.com/nginx/extending-nginx-tutorial</a></div><div class=""><br class=""></div><div class="">———————————————————————————————————————— </div><div class=""><div class="">static ngx_int_t ngx_http_l_handler(ngx_http_request_t *r) {</div><div class=""> if (r->main->internal) { //already processed</div><div class=""> return NGX_DECLINED;</div><div class=""> }</div><div class=""><br class=""></div><div class=""> r->main->internal = 1; // mark as processed</div><div class=""> </div><div class=""> ngx_table_elt_t *h;</div><div class=""> h = ngx_list_push(&r->headers_out.headers);</div><div class=""> h->hash = 1;</div><div class=""> ngx_str_set(&h->key, "X-NGINX-Tutorial");</div><div class=""> ngx_str_set(&h->value, "Hello World!");</div><div class=""> </div><div class=""> HandleRequest(); // calling go code here :)</div><div class=""> </div><div class=""> return NGX_DECLINED;</div><div class="">}</div></div><div class="">———————————————————————————————————————— </div><div class=""><br class=""></div><div class="">It just inject a HTTP header. It works fine, without the “HandleRequest()” call. “HandleRequest()” is a function coming from the Go code. This function is <b class="">empty and does nothing</b>. With this call, nginx just never finishes the response and is stuck. Here are the logs:</div><div class=""><br class=""></div><div class="">———————————————————————————————————————— </div><div class=""><div class="">2016/04/21 21:57:01 [debug] 33#0: epoll: fd:6 ev:0001 d:00007FC064EA9010</div><div class="">2016/04/21 21:57:01 [debug] 33#0: accept on 0.0.0.0:8888, ready: 0</div><div class="">2016/04/21 21:57:01 [debug] 33#0: posix_memalign: 00000000007426F0:512 @16</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 accept: 127.0.0.1:43842 fd:3</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 event timer add: 3: 60000:1461275881230</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 reusable connection: 1</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 epoll add event: fd:3 op:1 ev:80002001</div><div class="">2016/04/21 21:57:01 [debug] 33#0: timer delta: 17268</div><div class="">2016/04/21 21:57:01 [debug] 33#0: worker cycle</div><div class="">2016/04/21 21:57:01 [debug] 33#0: epoll timer: 60000</div><div class="">2016/04/21 21:57:01 [debug] 33#0: epoll: fd:3 ev:0001 d:00007FC064EA91B0</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http wait request handler</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 malloc: 0000000000742900:1024</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 recv: fd:3 78 of 1024</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 reusable connection: 0</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 posix_memalign: 0000000000742D10:4096 @16</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http process request line</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http request line: "GET / HTTP/1.1"</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http uri: "/"</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http args: ""</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http exten: ""</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http process request header line</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http header: "User-Agent: curl/7.35.0"</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http header: "Host: 127.0.0.1:8888"</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http header: "Accept: */*"</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http header done</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 event timer del: 3: 1461275881230</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 rewrite phase: 0</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 test location: "/"</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 using configuration "/"</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 http cl:-1 max:1048576</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 rewrite phase: 2</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 post rewrite phase: 3</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 generic phase: 4</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 generic phase: 5</div><div class="">2016/04/21 21:57:01 [debug] 33#0: *1 access phase: 6</div></div><div class=""><br class=""></div><div class="">// stuck here nothing will happen next ...</div><div class="">———————————————————————————————————————— </div><div class=""><br class=""></div><div class="">I have no warning or error during the compilation of my module. Any idea of where this behaviour could come from ?</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Robin</div><div class=""><br class=""></div></body></html>