Skip to content

Commit 5b9990d

Browse files
committed
Always use our async DNS in callback interface
Our own async DNS has been "upgraded to full membership". It's now used always in the callback interface on POSIX and Windows and OpenSSL. This avoids the ugly blocking behavior of getaddrinfo(), which is most ugly when there's trouble w/networking. A few more samples were added, illustrating common usage patterns, though they are somewhat "initial", will be improved with time. Also, most samples are fixed to make nice w/HTTP keep-alive. Functional tests ditto (though it seems there's some more work needed there, especially on OpenSSL).
1 parent ab692e9 commit 5b9990d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2308
-565
lines changed

.pubnub.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: c-core
2-
version: 2.3.4
2+
version: 2.4.0
33
scm: github.com/pubnub/c-core
44
changelog:
5-
- version: v2.3.4
5+
- version: v2.4.0
6+
- type: feature
7+
text: Callback interface uses (our own) async DNS
68
- type: feature
79
text: Enable sending meta data when publishing
810
- type: feature

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.4
1+
2.4.0

core/fntest/pubnub_fntest.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#include "core/pubnub_coreapi.h"
44
#include "core/pubnub_assert.h"
55
#include "pubnub_internal.h"
6+
#include "core/pubnub_ntf_sync.h"
7+
#include "core/pubnub_alloc.h"
68

7-
#include "core/fntest/pubnub_fntest.h"
9+
#include "pubnub_fntest.h"
810

911
#include <string.h>
1012
#include <stdarg.h>
@@ -109,10 +111,7 @@ bool pnfntst_subscribe_and_check(pubnub_t *p, char const *channel, char const*ch
109111
pnfntst_start_timer(tmr, ms);
110112
while (pnfntst_timer_is_running(tmr) && missing) {
111113
enum pubnub_res pbres = pubnub_subscribe(p, channel, chgroup);
112-
if (PNR_STARTED != pbres) {
113-
puts("subscribe and check: subscribe failed");
114-
break;
115-
}
114+
if (PNR_STARTED == pbres) {
116115
while (pnfntst_timer_is_running(tmr)) {
117116
pbres = pubnub_last_result(p);
118117
if (pbres != PNR_STARTED) {
@@ -123,7 +122,10 @@ bool pnfntst_subscribe_and_check(pubnub_t *p, char const *channel, char const*ch
123122
printf("subscribe and check: subscribe error %d\n", pbres);
124123
break;
125124
}
126-
125+
} else if (pbres != PNR_OK) {
126+
puts("subscribe and check: subscribe failed");
127+
break;
128+
}
127129
for (;;) {
128130
size_t i;
129131
char const *msg = pubnub_get(p);
@@ -146,3 +148,12 @@ bool pnfntst_subscribe_and_check(pubnub_t *p, char const *channel, char const*ch
146148

147149
return !missing;
148150
}
151+
152+
void pnfntst_free(pubnub_t *p)
153+
{
154+
pubnub_cancel(p);
155+
pubnub_await(p);
156+
if (pubnub_free(p) != 0) {
157+
printf("Failed to free the Pubnub context\n");
158+
}
159+
}

core/fntest/pubnub_fntest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ bool pnfntst_got_message_on_channel(pubnub_t *p, char const *message, char const
5151

5252

5353
bool pnfntst_subscribe_and_check(pubnub_t *p, char const *chan, char const*chgroup, unsigned ms, ...);
54+
void pnfntst_free(pubnub_t *p);
5455

5556
#include "fntest/pubnub_fntest_pal.h"
5657

0 commit comments

Comments
 (0)