Skip to content
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

Publish from other nginx modules and send channels events to internal locations #284

Open
wants to merge 88 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
60a1f47
Publish from other nginx modules
RekGRpth Oct 16, 2018
810e2d0
send channels events to internal locations
RekGRpth Oct 16, 2018
6a6dca7
publish from websocket to internal locations
RekGRpth Oct 19, 2018
029670d
publish from websocket to internal locations
RekGRpth Oct 23, 2018
8a467f7
publish from websocket to internal locations application/json
RekGRpth Oct 23, 2018
9d7ad4a
publish from websocket to internal locations
RekGRpth Oct 23, 2018
7a7a417
pool
RekGRpth Dec 20, 2018
215d5af
Merge remote-tracking branch 'upstream/master'
RekGRpth Feb 11, 2019
7ae15ed
all_worker_clients_unsubscribed
RekGRpth Sep 8, 2019
de7fa9a
notify
RekGRpth Sep 13, 2019
4109952
Delete from other nginx modeles
RekGRpth Sep 18, 2019
58814ca
temp_pool
RekGRpth Sep 20, 2019
a9117a4
include
RekGRpth Mar 25, 2020
48eb8c9
Merge remote-tracking branch 'upstream/master'
RekGRpth Apr 12, 2020
9b700f0
Merge remote-tracking branch 'upstream/master'
RekGRpth May 4, 2020
71cc50e
Bump rack from 2.2.2 to 2.2.3 in /misc
dependabot[bot] Aug 26, 2020
ecbc847
Merge pull request #1 from RekGRpth/dependabot/bundler/misc/rack-2.2.3
RekGRpth Aug 26, 2020
4f663a1
up
RekGRpth Sep 1, 2020
8623a2b
allow don't send same message twice and more
RekGRpth May 18, 2021
d601a75
Bump nokogiri from 1.10.9 to 1.11.4 in /misc
dependabot[bot] May 18, 2021
1c89c44
Merge pull request #2 from RekGRpth/dependabot/bundler/misc/nokogiri-…
RekGRpth May 18, 2021
0aef09e
return done if message already sent
RekGRpth May 19, 2021
b97401a
Merge branch 'master' of github.com:RekGRpth/nginx-push-stream-module
RekGRpth May 19, 2021
5ab6ad8
Bump em-http-request from 1.1.5 to 1.1.7 in /misc
dependabot[bot] May 24, 2021
93745bd
Merge pull request #3 from RekGRpth/dependabot/bundler/misc/em-http-r…
RekGRpth May 25, 2021
3db601c
static
RekGRpth Jun 8, 2021
115d7a9
fix
RekGRpth Jun 8, 2021
0ea7389
Bump addressable from 2.7.0 to 2.8.0 in /misc
dependabot[bot] Jul 13, 2021
7179eda
Merge pull request #4 from RekGRpth/dependabot/bundler/misc/addressab…
RekGRpth Jul 13, 2021
04ebd80
workflows
RekGRpth Jul 30, 2021
e496e43
dependabot
RekGRpth Jul 31, 2021
ad20651
merge
RekGRpth Jul 31, 2021
6796269
merge
RekGRpth Aug 1, 2021
56a8765
up
RekGRpth Aug 1, 2021
dd2bdb5
up
RekGRpth Aug 2, 2021
223f5da
merge
RekGRpth Aug 3, 2021
004cc8c
merge
RekGRpth Aug 4, 2021
dca8c58
up
RekGRpth Aug 4, 2021
7389f26
merge
RekGRpth Aug 4, 2021
b1c2504
up
RekGRpth Aug 6, 2021
f33c79c
merge
RekGRpth Aug 8, 2021
682ce93
merge
RekGRpth Aug 9, 2021
3869f06
Bump nokogiri from 1.11.4 to 1.12.5 in /misc
dependabot[bot] Sep 28, 2021
d785144
Merge pull request #5 from RekGRpth/dependabot/bundler/misc/nokogiri-…
RekGRpth Sep 28, 2021
da91059
Unused variable: channels_per_connection
RekGRpth Oct 8, 2021
2bec914
Variable 'bytes_written' is assigned a value that is never used
RekGRpth Oct 8, 2021
d663f12
make cppcheck happy
RekGRpth Nov 10, 2021
2439cef
Merge remote-tracking branch 'upstream/master'
actions-user Dec 1, 2021
b7b1027
Merge remote-tracking branch 'upstream/master'
RekGRpth Dec 12, 2021
84da57d
keepalive
actions-user Jan 31, 2022
930e5b6
Bump nokogiri from 1.12.5 to 1.13.2 in /misc
dependabot[bot] Feb 26, 2022
b809753
Merge pull request #6 from RekGRpth/dependabot/bundler/misc/nokogiri-…
RekGRpth Feb 26, 2022
f36a701
Bump nokogiri from 1.13.2 to 1.13.4 in /misc
dependabot[bot] Apr 12, 2022
bacdd02
Merge pull request #7 from RekGRpth/dependabot/bundler/misc/nokogiri-…
RekGRpth Apr 12, 2022
9e75dc7
fix
RekGRpth Apr 15, 2022
51e4f4c
Bump ejs from 3.1.6 to 3.1.8 in /misc
dependabot[bot] May 16, 2022
06c0a46
Merge pull request #8 from RekGRpth/dependabot/npm_and_yarn/misc/ejs-…
RekGRpth May 17, 2022
634da31
Bump nokogiri from 1.13.4 to 1.13.5 in /misc
dependabot[bot] May 19, 2022
38aed1a
Merge pull request #9 from RekGRpth/dependabot/bundler/misc/nokogiri-…
RekGRpth May 19, 2022
0297496
Bump nokogiri from 1.13.5 to 1.13.6 in /misc
dependabot[bot] May 24, 2022
ead73a5
Merge pull request #10 from RekGRpth/dependabot/bundler/misc/nokogiri…
RekGRpth May 24, 2022
0b8810f
Merge remote-tracking branch 'upstream/master'
RekGRpth Jun 28, 2022
b4d5bb0
keepalive
actions-user Aug 17, 2022
a1ad62c
keepalive
actions-user Oct 6, 2022
3fb2c71
Bump nokogiri from 1.13.6 to 1.13.9 in /misc
dependabot[bot] Oct 21, 2022
6ee44bc
Bump minimatch from 3.0.4 to 3.0.8 in /misc
dependabot[bot] Nov 12, 2022
03b79e3
Merge pull request #11 from RekGRpth/dependabot/bundler/misc/nokogiri…
RekGRpth Nov 13, 2022
bcfc433
Merge pull request #12 from RekGRpth/dependabot/npm_and_yarn/misc/min…
RekGRpth Nov 13, 2022
d10f3d3
keepalive
actions-user Jan 2, 2023
1f93ff3
keepalive
actions-user Feb 21, 2023
36cb8cd
keepalive
actions-user Apr 13, 2023
c41f540
Merge remote-tracking branch 'upstream/master'
actions-user Apr 20, 2023
1290b93
keepalive
actions-user Jun 10, 2023
1ad9769
keepalive
actions-user Jul 31, 2023
8ecaa0a
keepalive
actions-user Sep 19, 2023
c8d632b
keepalive
actions-user Nov 8, 2023
e3aac3e
angie
RekGRpth Dec 2, 2023
c949054
Merge branch 'master' of github.com:RekGRpth/nginx-push-stream-module
RekGRpth Dec 2, 2023
e9e9016
keepalive
actions-user Jan 21, 2024
9efb6e2
keepalive
actions-user Mar 11, 2024
ec2751c
freenginx
RekGRpth Apr 18, 2024
e1fc09e
Merge remote-tracking branch 'upstream/master'
RekGRpth May 7, 2024
1cf4a23
Merge remote-tracking branch 'upstream/master'
actions-user May 10, 2024
183fb82
keepalive
actions-user Jun 30, 2024
fd7508d
keepalive
actions-user Aug 19, 2024
3c09f63
keepalive
actions-user Oct 9, 2024
cb6864c
keepalive
actions-user Nov 28, 2024
3eeb332
keepalive
actions-user Jan 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
22 changes: 22 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Docker
on:
push:
branches:
- master
workflow_dispatch:
jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
INPUTS_CLIENT_PAYLOAD: '{"repository":${{ toJson(github.event.repository.name) }}}'
INPUTS_EVENT_TYPE: latest
INPUTS_REPOSITORY: ${{ github.repository_owner }}/${{ matrix.repo }}
uses: rekgrpth/github-repository-dispatch-shell-action@v1
strategy:
matrix:
repo:
- angie.docker
- freenginx.docker
- nginx.docker
15 changes: 15 additions & 0 deletions .github/workflows/merge-upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Merge
on:
schedule:
- cron: '0 19 * * *'
workflow_dispatch:
jobs:
merge:
env:
GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: rekgrpth/git-clone-shell-action@v1
- env:
INPUTS_REPOSITORY: wandenberg/nginx-push-stream-module
uses: rekgrpth/git-fetch-upstream-merge-push-shell-action@v1
1 change: 1 addition & 0 deletions .keepalive
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1737227723
2 changes: 1 addition & 1 deletion config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ngx_addon_name=ngx_http_push_stream_module
CORE_INCS="$CORE_INCS ${ngx_addon_dir}/src ${ngx_addon_dir}/include"
#CORE_INCS="$CORE_INCS ${ngx_addon_dir}/src ${ngx_addon_dir}/include"

if test -n "$ngx_module_link"; then
ngx_module_type=HTTP
Expand Down
6 changes: 6 additions & 0 deletions include/ngx_http_push_stream_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ typedef struct {
ngx_str_t padding_by_user_agent;
ngx_queue_t *paddings;
ngx_http_complex_value_t *allowed_origins;
ngx_http_complex_value_t *channel_created_request_url;
ngx_http_complex_value_t *channel_destroyed_request_url;
ngx_http_complex_value_t *all_worker_clients_unsubscribed_request_url;
ngx_http_complex_value_t *client_subscribed_request_url;
ngx_http_complex_value_t *client_unsubscribed_request_url;
ngx_http_complex_value_t *client_publish_request_url;
} ngx_http_push_stream_loc_conf_t;

// shared memory segment name
Expand Down
4 changes: 2 additions & 2 deletions include/ngx_http_push_stream_module_ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#ifndef NGX_HTTP_PUSH_STREAM_MODULE_IPC_H_
#define NGX_HTTP_PUSH_STREAM_MODULE_IPC_H_

#include <ngx_http_push_stream_module.h>
#include <ngx_http_push_stream_module_subscriber.h>
#include "ngx_http_push_stream_module.h"
#include "ngx_http_push_stream_module_subscriber.h"

#include <ngx_channel.h>

Expand Down
2 changes: 1 addition & 1 deletion include/ngx_http_push_stream_module_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef NGX_HTTP_PUSH_STREAM_MODULE_PUBLISHER_H_
#define NGX_HTTP_PUSH_STREAM_MODULE_PUBLISHER_H_

#include <ngx_http_push_stream_module.h>
#include "ngx_http_push_stream_module.h"

static ngx_int_t ngx_http_push_stream_channels_statistics_handler(ngx_http_request_t *r);
static ngx_int_t ngx_http_push_stream_publisher_handler(ngx_http_request_t *r);
Expand Down
14 changes: 7 additions & 7 deletions include/ngx_http_push_stream_module_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#ifndef NGX_HTTP_PUSH_STREAM_MODULE_SETUP_H_
#define NGX_HTTP_PUSH_STREAM_MODULE_SETUP_H_

#include <ngx_http_push_stream_module.h>
#include <ngx_http_push_stream_rbtree_util.h>
#include <ngx_http_push_stream_module_utils.h>
#include <ngx_http_push_stream_module_ipc.h>
#include <ngx_http_push_stream_module_publisher.h>
#include <ngx_http_push_stream_module_subscriber.h>
#include <ngx_http_push_stream_module_websocket.h>
#include "ngx_http_push_stream_module.h"
#include "ngx_http_push_stream_rbtree_util.h"
#include "ngx_http_push_stream_module_utils.h"
#include "ngx_http_push_stream_module_ipc.h"
#include "ngx_http_push_stream_module_publisher.h"
#include "ngx_http_push_stream_module_subscriber.h"
#include "ngx_http_push_stream_module_websocket.h"

#define NGX_HTTP_PUSH_STREAM_MESSAGE_BUFFER_CLEANUP_INTERVAL 5000 // 5 seconds
static time_t NGX_HTTP_PUSH_STREAM_DEFAULT_SHM_MEMORY_CLEANUP_OBJECTS_TTL = 10; // 10 seconds
Expand Down
10 changes: 7 additions & 3 deletions include/ngx_http_push_stream_module_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#ifndef NGX_HTTP_PUSH_STREAM_MODULE_UTILS_H_
#define NGX_HTTP_PUSH_STREAM_MODULE_UTILS_H_

#include <ngx_http_push_stream_module.h>
#include <ngx_http_push_stream_module_ipc.h>
#include "ngx_http_push_stream_module.h"
#include "ngx_http_push_stream_module_ipc.h"

typedef struct {
ngx_queue_t queue;
Expand Down Expand Up @@ -229,6 +229,7 @@ static ngx_str_t NGX_HTTP_PUSH_STREAM_EVENT_TYPE_CHANNEL_CREATED = ngx_string("
static ngx_str_t NGX_HTTP_PUSH_STREAM_EVENT_TYPE_CHANNEL_DESTROYED = ngx_string("channel_destroyed");
static ngx_str_t NGX_HTTP_PUSH_STREAM_EVENT_TYPE_CLIENT_SUBSCRIBED = ngx_string("client_subscribed");
static ngx_str_t NGX_HTTP_PUSH_STREAM_EVENT_TYPE_CLIENT_UNSUBSCRIBED = ngx_string("client_unsubscribed");
static ngx_str_t NGX_HTTP_PUSH_STREAM_POST = ngx_string("POST");


ngx_event_t ngx_http_push_stream_memory_cleanup_event;
Expand All @@ -252,6 +253,7 @@ static ngx_int_t ngx_http_push_stream_send_response_content_header(ng
static ngx_int_t ngx_http_push_stream_send_response(ngx_http_request_t *r, ngx_str_t *text, const ngx_str_t *content_type, ngx_int_t status_code);
static ngx_int_t ngx_http_push_stream_send_response_message(ngx_http_request_t *r, ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *msg, ngx_flag_t send_callback, ngx_flag_t send_separator);
static ngx_int_t ngx_http_push_stream_send_response_text(ngx_http_request_t *r, const u_char *text, uint len, ngx_flag_t last_buffer);
static ngx_int_t ngx_http_push_stream_output_filter(ngx_http_request_t *r, ngx_chain_t *in);
static void ngx_http_push_stream_send_response_finalize(ngx_http_request_t *r);
static void ngx_http_push_stream_send_response_finalize_for_longpolling_by_timeout(ngx_http_request_t *r);
static ngx_int_t ngx_http_push_stream_send_websocket_close_frame(ngx_http_request_t *r, ngx_uint_t http_status, const ngx_str_t *reason);
Expand All @@ -263,7 +265,8 @@ static void ngx_http_push_stream_complex_value(ngx_http_request_


ngx_int_t ngx_http_push_stream_add_msg_to_channel(ngx_http_push_stream_main_conf_t *mcf, ngx_log_t *log, ngx_http_push_stream_channel_t *channel, u_char *text, size_t len, ngx_str_t *event_id, ngx_str_t *event_type, ngx_flag_t store_messages, ngx_pool_t *temp_pool);
ngx_int_t ngx_http_push_stream_send_event(ngx_http_push_stream_main_conf_t *mcf, ngx_log_t *log, ngx_http_push_stream_channel_t *channel, ngx_str_t *event_id, ngx_pool_t *temp_pool);
ngx_int_t ngx_http_push_stream_add_msg_to_channel_my(ngx_log_t *log, ngx_str_t *id, ngx_str_t *text, ngx_str_t *event_id, ngx_str_t *event_type, ngx_flag_t store_messages, ngx_pool_t *temp_pool);
ngx_int_t ngx_http_push_stream_send_event(ngx_http_push_stream_main_conf_t *mcf, ngx_log_t *log, ngx_http_push_stream_channel_t *channel, ngx_str_t *event_id, ngx_pool_t *temp_pool, ngx_http_request_t *r, ngx_http_complex_value_t *uri);

static void ngx_http_push_stream_ping_timer_wake_handler(ngx_event_t *ev);
static void ngx_http_push_stream_disconnect_timer_wake_handler(ngx_event_t *ev);
Expand All @@ -281,6 +284,7 @@ static ngx_str_t * ngx_http_push_stream_create_str(ngx_pool_t *pool, ui

static void ngx_http_push_stream_throw_the_message_away(ngx_http_push_stream_msg_t *msg, ngx_http_push_stream_shm_data_t *data);
static ngx_int_t ngx_http_push_stream_delete_channel(ngx_http_push_stream_main_conf_t *mcf, ngx_http_push_stream_channel_t *channel, u_char *text, size_t len, ngx_pool_t *temp_pool);
ngx_int_t ngx_http_push_stream_delete_channel_my(ngx_log_t *log, ngx_str_t *id, u_char *text, size_t len, ngx_pool_t *temp_pool);
static void ngx_http_push_stream_collect_expired_messages_data(ngx_http_push_stream_shm_data_t *data, ngx_flag_t force);
static void ngx_http_push_stream_collect_expired_messages_and_empty_channels(ngx_flag_t force);
static void ngx_http_push_stream_free_message_memory(ngx_slab_pool_t *shpool, ngx_http_push_stream_msg_t *msg);
Expand Down
4 changes: 2 additions & 2 deletions include/ngx_http_push_stream_module_websocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include <ngx_sha1.h>
#endif

#include <ngx_http_push_stream_module_utils.h>
#include <ngx_http_push_stream_module_subscriber.h>
#include "ngx_http_push_stream_module_utils.h"
#include "ngx_http_push_stream_module_subscriber.h"

static ngx_int_t ngx_http_push_stream_websocket_handler(ngx_http_request_t *r);

Expand Down
2 changes: 1 addition & 1 deletion include/ngx_http_push_stream_rbtree_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#ifndef NGX_HTTP_PUSH_STREAM_RBTREE_UTIL_H_
#define NGX_HTTP_PUSH_STREAM_RBTREE_UTIL_H_

static ngx_http_push_stream_channel_t * ngx_http_push_stream_get_channel(ngx_str_t *id, ngx_log_t *log, ngx_http_push_stream_main_conf_t *mcf);
static ngx_http_push_stream_channel_t * ngx_http_push_stream_get_channel(ngx_str_t *id, ngx_log_t *log, ngx_http_push_stream_main_conf_t *mcf, ngx_http_request_t *r);
static ngx_http_push_stream_channel_t * ngx_http_push_stream_find_channel(ngx_str_t *id, ngx_log_t *log, ngx_http_push_stream_main_conf_t *mcf);

static void ngx_rbtree_generic_insert(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel, int (*compare) (const ngx_rbtree_node_t *left, const ngx_rbtree_node_t *right));
Expand Down
2 changes: 1 addition & 1 deletion misc/tools/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void
write_message(Connection *connection, Statistics *stats)
{
char buffer[BUFFER_SIZE];
int len = 0, bytes_written = 0;
int len = 0;

if ((connection->channel_id <= connection->channel_start) || (connection->channel_id > connection->channel_end)) {
connection->channel_id = connection->channel_start;
Expand Down
4 changes: 2 additions & 2 deletions misc/tools/subscriber.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int
main_program(int num_channels, int num_connections, const char *server_hostname, int server_port, int timeout)
{
struct sockaddr_in server_address;
int main_sd = -1, num_events = 0, i, j, event_mask, channels_per_connection, num, start_time = 0, iters_to_next_summary = 0;
int main_sd = -1, num_events = 0, i, j, event_mask, num, start_time = 0, iters_to_next_summary = 0;
Connection *connections = NULL, *connection;
Statistics stats = {0,0,0,0,0};
int exitcode = EXIT_SUCCESS;
Expand Down Expand Up @@ -138,7 +138,7 @@ void
subscribe_channels(Connection *connection, Statistics *stats)
{
char buffer[BUFFER_SIZE];
int len = 0, bytes_written = 0;
int len = 0;
long i = 0;

len = sprintf(buffer, "GET /sub");
Expand Down
16 changes: 8 additions & 8 deletions src/ngx_http_push_stream_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
* Authors: Wandenberg Peixoto <[email protected]>, Rogério Carvalho Schneider <[email protected]>
*/

#include <ngx_http_push_stream_module.h>
#include <ngx_http_push_stream_module_setup.c>
#include <ngx_http_push_stream_rbtree_util.c>
#include <ngx_http_push_stream_module_utils.c>
#include <ngx_http_push_stream_module_ipc.c>
#include <ngx_http_push_stream_module_publisher.c>
#include <ngx_http_push_stream_module_subscriber.c>
#include <ngx_http_push_stream_module_websocket.c>
#include "ngx_http_push_stream_module.h"
#include "ngx_http_push_stream_module_setup.c"
#include "ngx_http_push_stream_rbtree_util.c"
#include "ngx_http_push_stream_module_utils.c"
#include "ngx_http_push_stream_module_ipc.c"
#include "ngx_http_push_stream_module_publisher.c"
#include "ngx_http_push_stream_module_subscriber.c"
#include "ngx_http_push_stream_module_websocket.c"

static ngx_str_t *
ngx_http_push_stream_channel_info_formatted(ngx_pool_t *pool, const ngx_str_t *format, ngx_str_t *id, ngx_uint_t published_messages, ngx_uint_t stored_messages, ngx_uint_t subscribers)
Expand Down
1 change: 1 addition & 0 deletions src/ngx_http_push_stream_module.h
2 changes: 1 addition & 1 deletion src/ngx_http_push_stream_module_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Modifications by: Wandenberg Peixoto <[email protected]>, Rogério Carvalho Schneider <[email protected]>
*/

#include <ngx_http_push_stream_module_ipc.h>
#include "ngx_http_push_stream_module_ipc.h"

void ngx_http_push_stream_ipc_init_worker_data(ngx_http_push_stream_shm_data_t *data);
static ngx_inline void ngx_http_push_stream_census_worker_subscribers_data(ngx_http_push_stream_shm_data_t *data);
Expand Down
1 change: 1 addition & 0 deletions src/ngx_http_push_stream_module_ipc.h
6 changes: 3 additions & 3 deletions src/ngx_http_push_stream_module_publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* Authors: Wandenberg Peixoto <[email protected]>, Rogério Carvalho Schneider <[email protected]>
*/

#include <ngx_http_push_stream_module_publisher.h>
#include <ngx_http_push_stream_module_version.h>
#include "ngx_http_push_stream_module_publisher.h"
#include "ngx_http_push_stream_module_version.h"

static ngx_int_t ngx_http_push_stream_publisher_handle_after_read_body(ngx_http_request_t *r, ngx_http_client_body_handler_pt post_handler);

Expand Down Expand Up @@ -97,7 +97,7 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)

if (r->method & (NGX_HTTP_POST|NGX_HTTP_PUT)) {
// create the channel if doesn't exist
requested_channel->channel = ngx_http_push_stream_get_channel(requested_channel->id, r->connection->log, mcf);
requested_channel->channel = ngx_http_push_stream_get_channel(requested_channel->id, r->connection->log, mcf, r);
if (requested_channel->channel == NULL) {
return ngx_http_push_stream_send_only_header_response(r, NGX_HTTP_INTERNAL_SERVER_ERROR, NULL);
}
Expand Down
1 change: 1 addition & 0 deletions src/ngx_http_push_stream_module_publisher.h
74 changes: 70 additions & 4 deletions src/ngx_http_push_stream_module_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Authors: Wandenberg Peixoto <[email protected]>, Rogério Carvalho Schneider <[email protected]>
*/

#include <ngx_http_push_stream_module_setup.h>
#include "ngx_http_push_stream_module_setup.h"

ngx_uint_t ngx_http_push_stream_padding_max_len = 0;
ngx_flag_t ngx_http_push_stream_enabled = 0;
Expand Down Expand Up @@ -249,6 +249,42 @@ static ngx_command_t ngx_http_push_stream_commands[] = {
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, allow_connections_to_events_channel),
NULL },
{ ngx_string("push_stream_channel_created_request"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, channel_created_request_url),
NULL } ,
{ ngx_string("push_stream_channel_destroyed_request"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, channel_destroyed_request_url),
NULL } ,
{ ngx_string("push_stream_all_worker_clients_unsubscribed_request"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, all_worker_clients_unsubscribed_request_url),
NULL } ,
{ ngx_string("push_stream_client_subscribed_request"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, client_subscribed_request_url),
NULL } ,
{ ngx_string("push_stream_client_unsubscribed_request"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, client_unsubscribed_request_url),
NULL } ,
{ ngx_string("push_stream_client_publish_request"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, client_publish_request_url),
NULL } ,

ngx_null_command
};
Expand Down Expand Up @@ -588,6 +624,12 @@ ngx_http_push_stream_create_loc_conf(ngx_conf_t *cf)
ngx_str_null(&lcf->padding_by_user_agent);
lcf->paddings = NULL;
lcf->allowed_origins = NULL;
lcf->channel_created_request_url = NULL;
lcf->channel_destroyed_request_url = NULL;
lcf->all_worker_clients_unsubscribed_request_url = NULL;
lcf->client_subscribed_request_url = NULL;
lcf->client_unsubscribed_request_url = NULL;
lcf->client_publish_request_url = NULL;

return lcf;
}
Expand Down Expand Up @@ -638,6 +680,30 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
conf->allowed_origins = prev->allowed_origins ;
}

if (conf->channel_created_request_url == NULL) {
conf->channel_created_request_url = prev->channel_created_request_url ;
}

if (conf->channel_destroyed_request_url == NULL) {
conf->channel_destroyed_request_url = prev->channel_destroyed_request_url ;
}

if (conf->all_worker_clients_unsubscribed_request_url == NULL) {
conf->all_worker_clients_unsubscribed_request_url = prev->all_worker_clients_unsubscribed_request_url ;
}

if (conf->client_subscribed_request_url == NULL) {
conf->client_subscribed_request_url = prev->client_subscribed_request_url ;
}

if (conf->client_unsubscribed_request_url == NULL) {
conf->client_unsubscribed_request_url = prev->client_unsubscribed_request_url ;
}

if (conf->client_publish_request_url == NULL) {
conf->client_publish_request_url = prev->client_publish_request_url ;
}

if (conf->location_type == NGX_CONF_UNSET_UINT) {
return NGX_CONF_OK;
}
Expand Down Expand Up @@ -872,14 +938,14 @@ ngx_http_push_stream_subscriber(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}

if (*field == NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_WEBSOCKET) {
char *rc = ngx_http_push_stream_setup_handler(cf, conf, &ngx_http_push_stream_websocket_handler);
#if (NGX_HAVE_SHA1)
char *rc = ngx_http_push_stream_setup_handler(cf, conf, &ngx_http_push_stream_websocket_handler);
if (rc == NGX_CONF_OK) {
ngx_http_push_stream_loc_conf_t *pslcf = conf;
pslcf->location_type = NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_WEBSOCKET;
}
#else
rc = NGX_CONF_ERROR;
char *rc = NGX_CONF_ERROR;
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "push stream module: push stream module: sha1 support is needed to use WebSocket");
#endif
return rc;
Expand Down Expand Up @@ -1131,7 +1197,7 @@ ngx_http_push_stream_init_shm_zone(ngx_shm_zone_t *shm_zone, void *data)
d->mutex_round_robin = 0;

if (mcf->events_channel_id.len > 0) {
if ((d->events_channel = ngx_http_push_stream_get_channel(&mcf->events_channel_id, ngx_cycle->log, mcf)) == NULL) {
if ((d->events_channel = ngx_http_push_stream_get_channel(&mcf->events_channel_id, ngx_cycle->log, mcf, NULL)) == NULL) {
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "push stream module: unable to create events channel");
return NGX_ERROR;
}
Expand Down
1 change: 1 addition & 0 deletions src/ngx_http_push_stream_module_setup.h
Loading