agoo 2.5.5 → 2.5.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of agoo might be problematic. Click here for more details.

Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.md +1 -1
  4. data/ext/agoo/agoo.c +4 -3
  5. data/ext/agoo/atomic.h +120 -0
  6. data/ext/agoo/bind.c +52 -52
  7. data/ext/agoo/bind.h +13 -13
  8. data/ext/agoo/con.c +499 -481
  9. data/ext/agoo/con.h +47 -39
  10. data/ext/agoo/debug.c +42 -42
  11. data/ext/agoo/debug.h +1 -1
  12. data/ext/agoo/doc.c +17 -17
  13. data/ext/agoo/doc.h +12 -12
  14. data/ext/agoo/err.c +18 -18
  15. data/ext/agoo/err.h +27 -27
  16. data/ext/agoo/error_stream.c +9 -9
  17. data/ext/agoo/extconf.rb +3 -0
  18. data/ext/agoo/gqlintro.c +43 -43
  19. data/ext/agoo/gqlintro.h +1 -1
  20. data/ext/agoo/gqlvalue.c +131 -131
  21. data/ext/agoo/gqlvalue.h +32 -32
  22. data/ext/agoo/graphql.c +158 -158
  23. data/ext/agoo/graphql.h +34 -33
  24. data/ext/agoo/hook.c +15 -14
  25. data/ext/agoo/hook.h +18 -14
  26. data/ext/agoo/http.c +14 -14
  27. data/ext/agoo/http.h +4 -4
  28. data/ext/agoo/kinds.h +5 -5
  29. data/ext/agoo/log.c +232 -224
  30. data/ext/agoo/log.h +93 -93
  31. data/ext/agoo/method.h +17 -17
  32. data/ext/agoo/page.c +88 -86
  33. data/ext/agoo/page.h +21 -21
  34. data/ext/agoo/pub.c +36 -36
  35. data/ext/agoo/pub.h +23 -23
  36. data/ext/agoo/queue.c +37 -38
  37. data/ext/agoo/queue.h +20 -19
  38. data/ext/agoo/rack_logger.c +13 -13
  39. data/ext/agoo/ready.c +357 -0
  40. data/ext/agoo/ready.h +41 -0
  41. data/ext/agoo/req.c +11 -11
  42. data/ext/agoo/req.h +30 -31
  43. data/ext/agoo/request.c +46 -46
  44. data/ext/agoo/request.h +2 -2
  45. data/ext/agoo/res.c +40 -18
  46. data/ext/agoo/res.h +14 -14
  47. data/ext/agoo/response.c +6 -6
  48. data/ext/agoo/response.h +9 -9
  49. data/ext/agoo/rhook.c +3 -3
  50. data/ext/agoo/rhook.h +1 -1
  51. data/ext/agoo/rlog.c +47 -42
  52. data/ext/agoo/rlog.h +0 -1
  53. data/ext/agoo/rresponse.c +33 -33
  54. data/ext/agoo/rresponse.h +1 -1
  55. data/ext/agoo/rserver.c +184 -175
  56. data/ext/agoo/rserver.h +2 -2
  57. data/ext/agoo/rupgraded.c +41 -41
  58. data/ext/agoo/rupgraded.h +3 -3
  59. data/ext/agoo/sdl.c +80 -80
  60. data/ext/agoo/sdl.h +1 -1
  61. data/ext/agoo/seg.h +2 -2
  62. data/ext/agoo/server.c +143 -117
  63. data/ext/agoo/server.h +43 -42
  64. data/ext/agoo/sse.c +7 -7
  65. data/ext/agoo/sse.h +4 -4
  66. data/ext/agoo/subject.c +5 -5
  67. data/ext/agoo/subject.h +6 -6
  68. data/ext/agoo/text.c +21 -21
  69. data/ext/agoo/text.h +14 -13
  70. data/ext/agoo/upgraded.c +41 -40
  71. data/ext/agoo/upgraded.h +41 -40
  72. data/ext/agoo/websocket.c +42 -42
  73. data/ext/agoo/websocket.h +16 -16
  74. data/lib/agoo/version.rb +1 -1
  75. data/test/static_test.rb +2 -0
  76. metadata +5 -5
  77. data/ext/agoo/log_queue.h +0 -30
  78. data/ext/agoo/sub.c +0 -111
  79. data/ext/agoo/sub.h +0 -36
@@ -15,14 +15,14 @@ Connection: keep-alive\r\n\
15
15
  \r\n\
16
16
  retry: 5\n\n";
17
17
 
18
- Text
19
- sse_upgrade(Req req, Text t) {
18
+ agooText
19
+ agoo_sse_upgrade(agooReq req, agooText t) {
20
20
  t->len = 0; // reset
21
- return text_append(t, up, sizeof(up) - 1);
21
+ return agoo_text_append(t, up, sizeof(up) - 1);
22
22
  }
23
23
 
24
- Text
25
- sse_expand(Text t) {
26
- t = text_prepend(t, prefix, sizeof(prefix) - 1);
27
- return text_append(t, suffix, sizeof(suffix) - 1);
24
+ agooText
25
+ agoo_sse_expand(agooText t) {
26
+ t = agoo_text_prepend(t, prefix, sizeof(prefix) - 1);
27
+ return agoo_text_append(t, suffix, sizeof(suffix) - 1);
28
28
  }
@@ -3,10 +3,10 @@
3
3
  #ifndef AGOO_SSE_H
4
4
  #define AGOO_SSE_H
5
5
 
6
- struct _Req;
7
- struct _Text;
6
+ struct _agooReq;
7
+ struct _agooText;
8
8
 
9
- extern struct _Text* sse_upgrade(struct _Req *req, struct _Text *t);
10
- extern struct _Text* sse_expand(struct _Text *t);
9
+ extern struct _agooText* agoo_sse_upgrade(struct _agooReq *req, struct _agooText *t);
10
+ extern struct _agooText* agoo_sse_expand(struct _agooText *t);
11
11
 
12
12
  #endif // AGOO_SSE_H
@@ -7,9 +7,9 @@
7
7
  #include "debug.h"
8
8
  #include "subject.h"
9
9
 
10
- Subject
11
- subject_create(const char *pattern, int plen) {
12
- Subject subject = (Subject)malloc(sizeof(struct _Subject) - 7 + plen);
10
+ agooSubject
11
+ agoo_subject_create(const char *pattern, int plen) {
12
+ agooSubject subject = (agooSubject)malloc(sizeof(struct _agooSubject) - 7 + plen);
13
13
 
14
14
  if (NULL != subject) {
15
15
  DEBUG_ALLOC(mem_subject, subject);
@@ -21,13 +21,13 @@ subject_create(const char *pattern, int plen) {
21
21
  }
22
22
 
23
23
  void
24
- subject_destroy(Subject subject) {
24
+ agoo_subject_destroy(agooSubject subject) {
25
25
  DEBUG_FREE(mem_subject, subject);
26
26
  free(subject);
27
27
  }
28
28
 
29
29
  bool
30
- subject_check(Subject subj, const char *subject) {
30
+ agoo_subject_check(agooSubject subj, const char *subject) {
31
31
  const char *pat = subj->pattern;
32
32
 
33
33
  for (; '\0' != *pat && '\0' != *subject; subject++) {
@@ -5,13 +5,13 @@
5
5
 
6
6
  #include <stdbool.h>
7
7
 
8
- typedef struct _Subject {
9
- struct _Subject *next;
8
+ typedef struct _agooSubject {
9
+ struct _agooSubject *next;
10
10
  char pattern[8];
11
- } *Subject;
11
+ } *agooSubject;
12
12
 
13
- extern Subject subject_create(const char *pattern, int plen);
14
- extern void subject_destroy(Subject subject);
15
- extern bool subject_check(Subject subj, const char *subject);
13
+ extern agooSubject agoo_subject_create(const char *pattern, int plen);
14
+ extern void agoo_subject_destroy(agooSubject subject);
15
+ extern bool agoo_subject_check(agooSubject subj, const char *subject);
16
16
 
17
17
  #endif // AGOO_SUBJECT_H
@@ -7,9 +7,9 @@
7
7
  #include "debug.h"
8
8
  #include "text.h"
9
9
 
10
- Text
11
- text_create(const char *str, int len) {
12
- Text t = (Text)malloc(sizeof(struct _Text) - TEXT_MIN_SIZE + len + 1);
10
+ agooText
11
+ agoo_text_create(const char *str, int len) {
12
+ agooText t = (agooText)malloc(sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + len + 1);
13
13
 
14
14
  if (NULL != t) {
15
15
  DEBUG_ALLOC(mem_text, t)
@@ -23,9 +23,9 @@ text_create(const char *str, int len) {
23
23
  return t;
24
24
  }
25
25
 
26
- Text
27
- text_dup(Text t0) {
28
- Text t = (Text)malloc(sizeof(struct _Text) - TEXT_MIN_SIZE + t0->alen + 1);
26
+ agooText
27
+ agoo_text_dup(agooText t0) {
28
+ agooText t = (agooText)malloc(sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + t0->alen + 1);
29
29
 
30
30
  if (NULL != t) {
31
31
  DEBUG_ALLOC(mem_text, t)
@@ -38,9 +38,9 @@ text_dup(Text t0) {
38
38
  return t;
39
39
  }
40
40
 
41
- Text
42
- text_allocate(int len) {
43
- Text t = (Text)malloc(sizeof(struct _Text) - TEXT_MIN_SIZE + len + 1);
41
+ agooText
42
+ agoo_text_allocate(int len) {
43
+ agooText t = (agooText)malloc(sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + len + 1);
44
44
 
45
45
  if (NULL != t) {
46
46
  DEBUG_ALLOC(mem_text, t)
@@ -54,30 +54,30 @@ text_allocate(int len) {
54
54
  }
55
55
 
56
56
  void
57
- text_ref(Text t) {
57
+ agoo_text_ref(agooText t) {
58
58
  atomic_fetch_add(&t->ref_cnt, 1);
59
59
  }
60
60
 
61
61
  void
62
- text_release(Text t) {
62
+ agoo_text_release(agooText t) {
63
63
  if (1 >= atomic_fetch_sub(&t->ref_cnt, 1)) {
64
64
  DEBUG_FREE(mem_text, t);
65
65
  free(t);
66
66
  }
67
67
  }
68
68
 
69
- Text
70
- text_append(Text t, const char *s, int len) {
69
+ agooText
70
+ agoo_text_append(agooText t, const char *s, int len) {
71
71
  if (0 >= len) {
72
72
  len = (int)strlen(s);
73
73
  }
74
74
  if (t->alen <= t->len + len) {
75
75
  long new_len = t->alen + len + t->alen / 2;
76
- size_t size = sizeof(struct _Text) - TEXT_MIN_SIZE + new_len + 1;
76
+ size_t size = sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + new_len + 1;
77
77
  #ifdef MEM_DEBUG
78
- Text t0 = t;
78
+ agooText t0 = t;
79
79
  #endif
80
- if (NULL == (t = (Text)realloc(t, size))) {
80
+ if (NULL == (t = (agooText)realloc(t, size))) {
81
81
  return NULL;
82
82
  }
83
83
  DEBUG_REALLOC(mem_text, t0, t);
@@ -90,19 +90,19 @@ text_append(Text t, const char *s, int len) {
90
90
  return t;
91
91
  }
92
92
 
93
- Text
94
- text_prepend(Text t, const char *s, int len) {
93
+ agooText
94
+ agoo_text_prepend(agooText t, const char *s, int len) {
95
95
  if (0 >= len) {
96
96
  len = (int)strlen(s);
97
97
  }
98
98
  if (t->alen <= t->len + len) {
99
99
  long new_len = t->alen + len + t->alen / 2;
100
- size_t size = sizeof(struct _Text) - TEXT_MIN_SIZE + new_len + 1;
100
+ size_t size = sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + new_len + 1;
101
101
  #ifdef MEM_DEBUG
102
- Text t0 = t;
102
+ agooText t0 = t;
103
103
  #endif
104
104
 
105
- if (NULL == (t = (Text)realloc(t, size))) {
105
+ if (NULL == (t = (agooText)realloc(t, size))) {
106
106
  return NULL;
107
107
  }
108
108
  DEBUG_REALLOC(mem_text, t0, t);
@@ -3,25 +3,26 @@
3
3
  #ifndef AGOO_TEXT_H
4
4
  #define AGOO_TEXT_H
5
5
 
6
- #include <stdatomic.h>
7
6
  #include <stdbool.h>
8
7
 
9
- #define TEXT_MIN_SIZE 8
8
+ #include "atomic.h"
10
9
 
11
- typedef struct _Text {
10
+ #define AGOO_TEXT_MIN_SIZE 8
11
+
12
+ typedef struct _agooText {
12
13
  long len; // length of valid text
13
14
  long alen; // size of allocated text
14
15
  atomic_int ref_cnt;
15
16
  bool bin;
16
- char text[TEXT_MIN_SIZE];
17
- } *Text;
17
+ char text[AGOO_TEXT_MIN_SIZE];
18
+ } *agooText;
18
19
 
19
- extern Text text_create(const char *str, int len);
20
- extern Text text_dup(Text t);
21
- extern Text text_allocate(int len);
22
- extern void text_ref(Text t);
23
- extern void text_release(Text t);
24
- extern Text text_append(Text t, const char *s, int len);
25
- extern Text text_prepend(Text t, const char *s, int len);
20
+ extern agooText agoo_text_create(const char *str, int len);
21
+ extern agooText agoo_text_dup(agooText t);
22
+ extern agooText agoo_text_allocate(int len);
23
+ extern void agoo_text_ref(agooText t);
24
+ extern void agoo_text_release(agooText t);
25
+ extern agooText agoo_text_append(agooText t, const char *s, int len);
26
+ extern agooText agoo_text_prepend(agooText t, const char *s, int len);
26
27
 
27
- #endif /* AGOO_TEXT_H */
28
+ #endif // AGOO_TEXT_H
@@ -11,14 +11,14 @@
11
11
  #include "upgraded.h"
12
12
 
13
13
  static void
14
- destroy(Upgraded up) {
15
- Subject subject;
14
+ destroy(agooUpgraded up) {
15
+ agooSubject subject;
16
16
 
17
17
  if (NULL != up->on_destroy) {
18
18
  up->on_destroy(up);
19
19
  }
20
20
  if (NULL == up->prev) {
21
- the_server.up_list = up->next;
21
+ agoo_server.up_list = up->next;
22
22
  if (NULL != up->next) {
23
23
  up->next->prev = NULL;
24
24
  }
@@ -30,40 +30,40 @@ destroy(Upgraded up) {
30
30
  }
31
31
  while (NULL != (subject = up->subjects)) {
32
32
  up->subjects = up->subjects->next;
33
- subject_destroy(subject);
33
+ agoo_subject_destroy(subject);
34
34
  }
35
35
  DEBUG_FREE(mem_upgraded, up);
36
36
  free(up);
37
37
  }
38
38
 
39
39
  void
40
- upgraded_release(Upgraded up) {
41
- pthread_mutex_lock(&the_server.up_lock);
40
+ agoo_upgraded_release(agooUpgraded up) {
41
+ pthread_mutex_lock(&agoo_server.up_lock);
42
42
  if (atomic_fetch_sub(&up->ref_cnt, 1) <= 1) {
43
43
  destroy(up);
44
44
  }
45
- pthread_mutex_unlock(&the_server.up_lock);
45
+ pthread_mutex_unlock(&agoo_server.up_lock);
46
46
  }
47
47
 
48
48
  void
49
- upgraded_release_con(Upgraded up) {
50
- pthread_mutex_lock(&the_server.up_lock);
49
+ agoo_upgraded_release_con(agooUpgraded up) {
50
+ pthread_mutex_lock(&agoo_server.up_lock);
51
51
  up->con = NULL;
52
52
  if (atomic_fetch_sub(&up->ref_cnt, 1) <= 1) {
53
53
  destroy(up);
54
54
  }
55
- pthread_mutex_unlock(&the_server.up_lock);
55
+ pthread_mutex_unlock(&agoo_server.up_lock);
56
56
  }
57
57
 
58
58
  // Called from the con_loop thread, no need to lock, this steals the subject
59
59
  // so the pub subject should set to NULL
60
60
  void
61
- upgraded_add_subject(Upgraded up, Subject subject) {
62
- Subject s;
61
+ agoo_upgraded_add_subject(agooUpgraded up, agooSubject subject) {
62
+ agooSubject s;
63
63
 
64
64
  for (s = up->subjects; NULL != s; s = s->next) {
65
65
  if (0 == strcmp(subject->pattern, s->pattern)) {
66
- subject_destroy(subject);
66
+ agoo_subject_destroy(subject);
67
67
  return;
68
68
  }
69
69
  }
@@ -72,15 +72,15 @@ upgraded_add_subject(Upgraded up, Subject subject) {
72
72
  }
73
73
 
74
74
  void
75
- upgraded_del_subject(Upgraded up, Subject subject) {
75
+ agoo_upgraded_del_subject(agooUpgraded up, agooSubject subject) {
76
76
  if (NULL == subject) {
77
77
  while (NULL != (subject = up->subjects)) {
78
78
  up->subjects = up->subjects->next;
79
- subject_destroy(subject);
79
+ agoo_subject_destroy(subject);
80
80
  }
81
81
  } else {
82
- Subject s;
83
- Subject prev = NULL;
82
+ agooSubject s;
83
+ agooSubject prev = NULL;
84
84
 
85
85
  for (s = up->subjects; NULL != s; s = s->next) {
86
86
  if (0 == strcmp(subject->pattern, s->pattern)) {
@@ -89,7 +89,7 @@ upgraded_del_subject(Upgraded up, Subject subject) {
89
89
  } else {
90
90
  prev->next = s->next;
91
91
  }
92
- subject_destroy(s);
92
+ agoo_subject_destroy(s);
93
93
  break;
94
94
  }
95
95
  prev = s;
@@ -98,11 +98,11 @@ upgraded_del_subject(Upgraded up, Subject subject) {
98
98
  }
99
99
 
100
100
  bool
101
- upgraded_match(Upgraded up, const char *subject) {
102
- Subject s;
101
+ agoo_upgraded_match(agooUpgraded up, const char *subject) {
102
+ agooSubject s;
103
103
 
104
104
  for (s = up->subjects; NULL != s; s = s->next) {
105
- if (subject_check(s, subject)) {
105
+ if (agoo_subject_check(s, subject)) {
106
106
  return true;
107
107
  }
108
108
  }
@@ -110,15 +110,15 @@ upgraded_match(Upgraded up, const char *subject) {
110
110
  }
111
111
 
112
112
  void
113
- upgraded_ref(Upgraded up) {
113
+ agoo_upgraded_ref(agooUpgraded up) {
114
114
  atomic_fetch_add(&up->ref_cnt, 1);
115
115
  }
116
116
 
117
117
  bool
118
- upgraded_write(Upgraded up, const char *message, size_t mlen, bool bin, bool inc_ref) {
119
- Pub p;
118
+ agoo_upgraded_write(agooUpgraded up, const char *message, size_t mlen, bool bin, bool inc_ref) {
119
+ agooPub p;
120
120
 
121
- if (0 < the_server.max_push_pending && the_server.max_push_pending <= atomic_load(&up->pending)) {
121
+ if (0 < agoo_server.max_push_pending && agoo_server.max_push_pending <= (long)atomic_load(&up->pending)) {
122
122
  atomic_fetch_sub(&up->ref_cnt, 1);
123
123
  // Too many pending messages.
124
124
  return false;
@@ -126,57 +126,58 @@ upgraded_write(Upgraded up, const char *message, size_t mlen, bool bin, bool inc
126
126
  if (inc_ref) {
127
127
  atomic_fetch_add(&up->ref_cnt, 1);
128
128
  }
129
- p = pub_write(up, message, mlen, bin);
129
+ p = agoo_pub_write(up, message, mlen, bin);
130
130
  atomic_fetch_add(&up->pending, 1);
131
- server_publish(p);
131
+ agoo_server_publish(p);
132
132
 
133
133
  return true;
134
134
  }
135
135
 
136
136
  void
137
- upgraded_subscribe(Upgraded up, const char *subject, int slen, bool inc_ref) {
137
+ agoo_upgraded_subscribe(agooUpgraded up, const char *subject, int slen, bool inc_ref) {
138
138
  if (inc_ref) {
139
139
  atomic_fetch_add(&up->ref_cnt, 1);
140
140
  }
141
141
  atomic_fetch_add(&up->pending, 1);
142
- server_publish(pub_subscribe(up, subject, slen));
142
+ agoo_server_publish(agoo_pub_subscribe(up, subject, slen));
143
143
  }
144
144
 
145
145
  void
146
- upgraded_unsubscribe(Upgraded up, const char *subject, int slen, bool inc_ref) {
146
+ agoo_upgraded_unsubscribe(agooUpgraded up, const char *subject, int slen, bool inc_ref) {
147
147
  if (inc_ref) {
148
148
  atomic_fetch_add(&up->ref_cnt, 1);
149
149
  }
150
150
  atomic_fetch_add(&up->pending, 1);
151
- server_publish(pub_unsubscribe(up, subject, slen));
151
+ agoo_server_publish(agoo_pub_unsubscribe(up, subject, slen));
152
152
  }
153
153
 
154
154
  void
155
- upgraded_close(Upgraded up, bool inc_ref) {
155
+ agoo_upgraded_close(agooUpgraded up, bool inc_ref) {
156
156
  if (inc_ref) {
157
157
  atomic_fetch_add(&up->ref_cnt, 1);
158
158
  }
159
159
  atomic_fetch_add(&up->pending, 1);
160
- server_publish(pub_close(up));
160
+ agoo_server_publish(agoo_pub_close(up));
161
161
  }
162
162
 
163
163
  int
164
- upgraded_pending(Upgraded up) {
165
- return atomic_load(&up->pending);
164
+ agoo_upgraded_pending(agooUpgraded up) {
165
+ return (int)(long)atomic_load(&up->pending);
166
166
  }
167
167
 
168
- Upgraded
169
- upgraded_create(Con c, void * ctx, void *env) {
170
- Upgraded up = (Upgraded)malloc(sizeof(struct _Upgraded));
168
+ agooUpgraded
169
+ agoo_upgraded_create(agooCon c, void * ctx, void *env) {
170
+ agooUpgraded up = (agooUpgraded)malloc(sizeof(struct _agooUpgraded));
171
171
 
172
172
  if (NULL != up) {
173
173
  DEBUG_ALLOC(mem_upgraded, up);
174
- memset(up, 0, sizeof(struct _Upgraded));
174
+ memset(up, 0, sizeof(struct _agooUpgraded));
175
175
  up->con = c;
176
176
  up->ctx = ctx;
177
177
  up->env = env;
178
178
  atomic_init(&up->pending, 0);
179
- atomic_init(&up->ref_cnt, 1); // start with 1 for the Con reference
179
+ atomic_init(&up->ref_cnt, 0);
180
+ atomic_store(&up->ref_cnt, 1); // start with 1 for the Con reference
180
181
  }
181
182
  return up;
182
183
  }
@@ -4,48 +4,49 @@
4
4
  #define AGOO_UPGRADED_H
5
5
 
6
6
  #include <pthread.h>
7
- #include <stdatomic.h>
8
7
  #include <stdint.h>
9
8
  #include <stdbool.h>
10
9
 
11
- struct _Con;
12
- struct _Subject;
13
-
14
- typedef struct _Upgraded {
15
- struct _Upgraded *next;
16
- struct _Upgraded *prev;
17
- struct _Con *con;
18
- atomic_int pending;
19
- atomic_int ref_cnt;
20
- struct _Subject *subjects;
21
-
22
- void *ctx;
23
- void *wrap;
24
- void *env;
25
-
26
- bool on_empty;
27
- bool on_close;
28
- bool on_shut;
29
- bool on_msg;
30
- bool on_error;
31
- void (*on_destroy)(struct _Upgraded *up);
32
- } *Upgraded;
33
-
34
- extern Upgraded upgraded_create(struct _Con *c, void * ctx, void *env);
35
-
36
- extern void upgraded_release(Upgraded up);
37
- extern void upgraded_release_con(Upgraded up);
38
-
39
- extern void upgraded_ref(Upgraded up);
40
-
41
- extern void upgraded_add_subject(Upgraded up, struct _Subject *subject);
42
- extern void upgraded_del_subject(Upgraded up, struct _Subject *subject);
43
- extern bool upgraded_match(Upgraded up, const char *subject);
44
-
45
- extern bool upgraded_write(Upgraded up, const char *message, size_t mlen, bool bin, bool inc_ref);
46
- extern void upgraded_subscribe(Upgraded up, const char *subject, int slen, bool inc_ref);
47
- extern void upgraded_unsubscribe(Upgraded up, const char *subject, int slen, bool inc_ref);
48
- extern void upgraded_close(Upgraded up, bool inc_ref);
49
- extern int upgraded_pending(Upgraded up);
10
+ #include "atomic.h"
11
+
12
+ struct _agooCon;
13
+ struct _agooSubject;
14
+
15
+ typedef struct _agooUpgraded {
16
+ struct _agooUpgraded *next;
17
+ struct _agooUpgraded *prev;
18
+ struct _agooCon *con;
19
+ atomic_int pending;
20
+ atomic_int ref_cnt;
21
+ struct _agooSubject *subjects;
22
+
23
+ void *ctx;
24
+ void *wrap;
25
+ void *env;
26
+
27
+ bool on_empty;
28
+ bool on_close;
29
+ bool on_shut;
30
+ bool on_msg;
31
+ bool on_error;
32
+ void (*on_destroy)(struct _agooUpgraded *up);
33
+ } *agooUpgraded;
34
+
35
+ extern agooUpgraded agoo_upgraded_create(struct _agooCon *c, void * ctx, void *env);
36
+
37
+ extern void agoo_upgraded_release(agooUpgraded up);
38
+ extern void agoo_upgraded_release_con(agooUpgraded up);
39
+
40
+ extern void agoo_upgraded_ref(agooUpgraded up);
41
+
42
+ extern void agoo_upgraded_add_subject(agooUpgraded up, struct _agooSubject *subject);
43
+ extern void agoo_upgraded_del_subject(agooUpgraded up, struct _agooSubject *subject);
44
+ extern bool agoo_upgraded_match(agooUpgraded up, const char *subject);
45
+
46
+ extern bool agoo_upgraded_write(agooUpgraded up, const char *message, size_t mlen, bool bin, bool inc_ref);
47
+ extern void agoo_upgraded_subscribe(agooUpgraded up, const char *subject, int slen, bool inc_ref);
48
+ extern void agoo_upgraded_unsubscribe(agooUpgraded up, const char *subject, int slen, bool inc_ref);
49
+ extern void agoo_upgraded_close(agooUpgraded up, bool inc_ref);
50
+ extern int agoo_upgraded_pending(agooUpgraded up);
50
51
 
51
52
  #endif // AGOO_UPGRADED_H