Skip to content

Ability to build as dynamic module #47

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

Closed
cryptofuture opened this issue Apr 30, 2016 · 7 comments
Closed

Ability to build as dynamic module #47

cryptofuture opened this issue Apr 30, 2016 · 7 comments

Comments

@cryptofuture
Copy link

I wanted to convert module myself, but I can miss something (config with too many sections). Currently this is only one non dynamic module I currently use.

@agentzh
Copy link
Contributor

agentzh commented May 3, 2016

@cryptofuture Patches welcome :)

@cryptofuture
Copy link
Author

Tried today:
/etc/nginx/modules/ngx_postgres.so: undefined symbol: ngx_postgres
Seems like changing ngx_module_type makes no difference in end .so file. (tried HTTP and CORE too)
config I used and changes.
Any ideas? Should I write to nginx mailing list?

@agentzh
Copy link
Contributor

agentzh commented May 4, 2016

@cryptofuture The value of ngx_module_name variable in your config is wrong. Should be something like ngx_postgres_module instead to be consistent with the definition in the C code base. Maybe we should change it to ngx_http_postgres_module to be consistent with other nginx http C modules further. @PiotrSikora ?

@cryptofuture
Copy link
Author

Thanks, will try build tomorrow. ngx_http_postgres_module makes more sense.

@cryptofuture
Copy link
Author

Tried build today as dynamic, now undefined symbol: PQsendQuery
from ngx_http_postgres_processor.c source:

ngx_postgres_upstream_send_query(ngx_http_request_t *r, ngx_connection_t *pgxc,
    ngx_postgres_upstream_peer_data_t *pgdt)
{
    ngx_postgres_loc_conf_t  *pglcf;
    ngx_int_t                 pgrc;
    u_char                   *query;

    dd("entering");

    pglcf = ngx_http_get_module_loc_conf(r, ngx_postgres_module);

    query = ngx_pnalloc(r->pool, pgdt->query.len + 1);
    if (query == NULL) {
        dd("returning NGX_ERROR");
        return NGX_ERROR;
    }

    (void) ngx_cpystrn(query, pgdt->query.data, pgdt->query.len + 1);

    dd("sending query: %s", query);
    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pgxc->log, 0,
                   "postgres: sending query: \"%s\"", query);

    if (pglcf->output_binary) {
        pgrc = PQsendQueryParams(pgdt->pgconn, (const char *) query,
                                 0, NULL, NULL, NULL, NULL, /* binary */ 1);
    } else {
        pgrc = PQsendQuery(pgdt->pgconn, (const char *) query);
    }

    if (pgrc == 0) {
        dd("sending query failed");
        ngx_log_error(NGX_LOG_ERR, pgxc->log, 0,
                      "postgres: sending query failed: %s",
                      PQerrorMessage(pgdt->pgconn));

        dd("returning NGX_ERROR");
        return NGX_ERROR;
    }

    /* set result timeout */
    ngx_add_timer(pgxc->read, r->upstream->conf->read_timeout);

    dd("query sent successfully");
    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pgxc->log, 0,
                   "postgres: query sent successfully");

    pgxc->log->action = "waiting for result from PostgreSQL database";
    pgdt->state = state_db_get_result;

    dd("returning NGX_DONE");
    return NGX_DONE;
}

BTW moved all ngx_postgres reference to ngx_http_postgres locally (a lot changes), was hope I made some error, but ether way undefined symbol: PQsendQuery on module loading.

@agentzh
Copy link
Contributor

agentzh commented May 5, 2016

@cryptofuture You failed to link libpq against your own ngx_http_postgres_module.so, I guess.

@cryptofuture
Copy link
Author

Covered in #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants