- 
                Notifications
    
You must be signed in to change notification settings  - Fork 126
 
fix for issue #26 #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 
           @istr Your patch breaks the build on my side: Will you fix those? Also, it'll be great if you can add a test case for the corresponding issue to the existing test suite. Thanks!  | 
    
…rective. thanks Ingo Struck for the original patch in #29.
…rective. thanks Ingo Struck for the original patch in #29.
…rective. thanks Ingo Struck for the original patch in #29.
| 
           To be sure that it was not the fault of the ipv6 patch I ran the testsuite against master. The errors.t tests failing are due to my psql setup (allows login w/o credentials from localhost). It would be great if the test suite could somehow check and/or create the prerequisites for these tests and skip them if it finds that all local connections are allowed. Example of a failing bigpipe test:  | 
    
| 
           @istr The "TEST 3" in bigpipe.t uses the  The standard ngx_ssi module should be enabled by default in nginx. Are you explicitly disabling it in your nginx build with the  Regarding automatically skipping tests in errors.t, I don't think that is a good idea. The developers might accidentally introduce a regression that is covered by those skipped tests (and Murphy's Law always applies ;)).  | 
    
| 
           Ok, thanks for the hint wrt bigpipe. I tend to only compile in what is needed for each project. So my configuration looks like this: With "skipping" I did not mean "silently skipping" but skipping with an informative message, just like "skipping: this is not BeOS" and so on. Producing a test failure here might give a useful implicit hint that says: "maybe configuring your postgres to allow unconditional local access is not a good idea in most situations". An explicit skip / warning may be even more helpful, though: "skipping errors.t/2: your postgres allows local access without credentials given"  | 
    
| 
           @istr It'll require invoking psql or some other "trusted" Pg client to do the check. I'm just wondering if it's worth the trouble :) Anyway, patches welcome :)  | 
    
| 
           @istr Also, I still think letting the tests fail in this case is a good idea. People tend to be lazy and they won't bother reading any hints when they see "All tests successful". Failures are the best way to encourage people to investigate the issue.  | 
    
| 
           Wrt test failure: ok, your argument is right. :-) The pull request now contains: 
 The module passes the complete basic test suite using: 
 The integration with nginx-eval_module is NOT tested yet. It seems that the error.log is discarded too early to perform the "unknown directive" check.  | 
    
…ems to recover old repo
…rective. thanks Ingo Struck for the original patch in #29.
| 
           @istr Now the differences between my  diff --git a/src/ngx_postgres_keepalive.c b/src/ngx_postgres_keepalive.c
index 6f88563..df01cf9 100644
--- a/src/ngx_postgres_keepalive.c
+++ b/src/ngx_postgres_keepalive.c
@@ -130,7 +130,7 @@ ngx_postgres_keepalive_get_peer_multi(ngx_peer_connection_t *pc,
         item = ngx_queue_data(q, ngx_postgres_keepalive_cache_t, queue);
         c = item->connection;
-        if (ngx_memn2cmp((u_char *) &item->sockaddr, (u_char *) pc->sockaddr,
+        if (ngx_memn2cmp((u_char *) item->sockaddr, (u_char *) pc->sockaddr,
                 item->socklen, pc->socklen) == 0)
         {
             ngx_queue_remove(q);
@@ -243,7 +243,7 @@ ngx_postgres_keepalive_free_peer(ngx_peer_connection_t *pc,
         c->write->log = ngx_cycle->log;
         item->socklen = pc->socklen;
-        ngx_memcpy(&item->sockaddr, pc->sockaddr, pc->socklen);
+        ngx_memcpy(item->sockaddr, pc->sockaddr, pc->socklen);
         item->pgconn = pgp->pgconn;
You said you were seeing C compiler warnings (or errors with   | 
    
| 
           @istr Regarding  Will you try the latest git version here? https://github.com/openresty/test-nginx Thanks!  | 
    
| 
           @istr BTW, it's still recommended to compile in the ngx_eval module (https://github.com/openresty/nginx-eval-module ) to enable these tests on your side :)  | 
    
| 
           Ok, will try to compile in ngx_eval and run the full test suite. Maybe you can tell if this is a false positive.  | 
    
| 
           @istr Yes, it is a false positive due to an optimization in the LuaJIT VM. We usually run a special version of LuaJIT that disables such optimizations and also enables system allocators in LuaJIT (to prevent LuaJIT's own allocator from confusing valgrind, the same applies to nginx's own memory pools). For OpenResty, it's as easy as: ./configure --prefix=/opt/openresty-valgrind --with-debug --with-no-pool-patch \
          --with-luajit-xcflags='-DLUAJIT_USE_VALGRIND -DLUAJIT_USE_SYSMALLOC'If you really want to use the nginx 1.7.4 core with the OpenResty bundle, then use the following prerelease tarball instead: https://openresty.org/download/ngx_openresty-1.7.4.1rc0.tar.gz Do not replace OpenResty's own nginx core directly with the official version because certain things may break like the   | 
    
| 
           @istr FYI, for everyday C-level development, however, I usually use the following scripts to build everything (like ngx_postgres) instead of using the OpenResty bundle directly: http://agentzh.org/misc/nginx/ngx-postgres-build.sh https://github.com/openresty/nginx-devel-utils/tree/master/ngx-build Similar shell scripts are used for building custom LuaJIT and etc :)  | 
    
| 
           Ok, thanks for the hint wrt replacing nginx directly from vanilla sources. Up to now I never had any issue with that (maybe good luck?). Regarding your question to the diff beetween ipv6 branch and my master (now ipv6, too): I tend not to dereference what is already an address (uchar[...]) so I always prefer to write foo->bar instead of &foo->bar if feasible, even if it may be semantically equivalent.  | 
    
| 
           @istr I do understand your reasoning regarding  @PiotrSikora What's your opinion on this? I don't really mind actually :)  | 
    
| 
           @istr Yes, the pending issues are just on special code paths. You need some luck to trigger them but you still could (and some users indeed did in the past and that was exactly how they were discovered in the first place) ;)  | 
    
…rective. thanks Ingo Struck for the original patch in #29.
| 
           Closing, as there is a fix for the (more common) IPv6 part of it.  | 
    
…rective. thanks Ingo Struck for the original patch in #29.
Fix for issue #26. Finally it was easy to derive looking at the difference between src/ngx_postgres_keepalive.h and nginx src/http/modules/ngx_http_upstream_keepalive_module.c (ngx_http_upstream_keepalive_cache_t vs. ngx_postgres_keepalive_cache_t).
The key is to store the socket address in u_char sockaddr[NGX_SOCKADDRLEN] instead of struct sockaddr and memcpy where appropriate.
Please review and pull.