Skip to content

Commit

Permalink
Merge pull request #42 from pubnub/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MaxPresman authored Mar 10, 2018
2 parents 4856bbf + 10040e6 commit 7aa67d5
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 61 deletions.
8 changes: 6 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: c-core
version: 2.3.1
version: 2.3.2
scm: github.com/pubnub/c-core
changelog:
- version: v2.3.2
changes:
- type: bug
text: Unify default blocking I/O setting to block in sync and non-block in callback interface
- version: v2.3.1
changes:
- type: bug
text: Read from OpenSSL in a loop, to handle more than one record received at a time
- type: bug
text: Fix race condition in timer expiry
text: Fix minor race condition on timer expiry
- version: v2.3.0
changes:
- type: feature
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ the `develop` branch. Explain your fix in the PR comment (what it
fixes and how).

Please try to follow the existing coding style as much as possible and
avoid cosmetic (whitespace, code format) changes.
avoid cosmetic (whitespace, code format) changes. In fact, please use
`clang-format` with the supplied `.clang-format` configuration to
format the code before submitting a PR.

#### Adding new features

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.3.2
94 changes: 50 additions & 44 deletions core/pubnub_pubsubapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <ctype.h>


pubnub_t* pubnub_init(pubnub_t *p, const char *publish_key, const char *subscribe_key)
pubnub_t* pubnub_init(pubnub_t* p, const char* publish_key, const char* subscribe_key)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(p));

Expand All @@ -26,40 +26,47 @@ pubnub_t* pubnub_init(pubnub_t *p, const char *publish_key, const char *subscrib
#endif
}
#if defined(PUBNUB_CALLBACK_API)
p->cb = NULL;
p->user_data = NULL;
p->cb = NULL;
p->user_data = NULL;
#endif
if (PUBNUB_ORIGIN_SETTABLE) {
if (PUBNUB_ORIGIN_SETTABLE) {
p->origin = PUBNUB_ORIGIN;
}
if (PUBNUB_BLOCKING_IO_SETTABLE) {
#if defined(PUBNUB_CALLBACK_API)
p->options.use_blocking_io = false;
#else
p->options.use_blocking_io = true;
#endif
}

p->state = PBS_IDLE;
p->trans = PBTT_NONE;
p->state = PBS_IDLE;
p->trans = PBTT_NONE;
p->options.use_http_keep_alive = 1;
pbpal_init(p);
pubnub_mutex_unlock(p->monitor);

#if PUBNUB_PROXY_API
p->proxy_type = pbproxyNONE;
p->proxy_hostname[0] = '\0';
p->proxy_type = pbproxyNONE;
p->proxy_hostname[0] = '\0';
p->proxy_tunnel_established = false;
p->proxy_port = 80;
p->proxy_auth_scheme = pbhtauNone;
p->proxy_auth_username = NULL;
p->proxy_auth_password = NULL;
p->proxy_port = 80;
p->proxy_auth_scheme = pbhtauNone;
p->proxy_auth_username = NULL;
p->proxy_auth_password = NULL;
p->proxy_authorization_sent = false;
#endif

return p;
}


enum pubnub_res pubnub_publish(pubnub_t *pb, const char *channel, const char *message)
enum pubnub_res pubnub_publish(pubnub_t* pb, const char* channel, const char* message)
{
enum pubnub_res rslt;

PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));

pubnub_mutex_lock(pb->monitor);
if (!pbnc_can_start_transaction(pb)) {
pubnub_mutex_unlock(pb->monitor);
Expand All @@ -68,22 +75,20 @@ enum pubnub_res pubnub_publish(pubnub_t *pb, const char *channel, const char *me

rslt = pbcc_publish_prep(&pb->core, channel, message, true, false);
if (PNR_STARTED == rslt) {
pb->trans = PBTT_PUBLISH;
pb->trans = PBTT_PUBLISH;
pb->core.last_result = PNR_STARTED;
pbnc_fsm(pb);
rslt = pb->core.last_result;
}
pubnub_mutex_unlock(pb->monitor);

return rslt;
}




char const *pubnub_get(pubnub_t *pb)
char const* pubnub_get(pubnub_t* pb)
{
char const *result;
char const* result;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));

pubnub_mutex_lock(pb->monitor);
Expand All @@ -94,9 +99,9 @@ char const *pubnub_get(pubnub_t *pb)
}


char const *pubnub_get_channel(pubnub_t *pb)
char const* pubnub_get_channel(pubnub_t* pb)
{
char const *result;
char const* result;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));

pubnub_mutex_lock(pb->monitor);
Expand All @@ -107,33 +112,34 @@ char const *pubnub_get_channel(pubnub_t *pb)
}


enum pubnub_res pubnub_subscribe(pubnub_t *p, const char *channel, const char *channel_group)
enum pubnub_res pubnub_subscribe(pubnub_t* p,
const char* channel,
const char* channel_group)
{
enum pubnub_res rslt;

PUBNUB_ASSERT(pb_valid_ctx_ptr(p));

pubnub_mutex_lock(p->monitor);
if (!pbnc_can_start_transaction(p)) {
pubnub_mutex_unlock(p->monitor);
return PNR_IN_PROGRESS;
}

rslt = pbcc_subscribe_prep(&p->core, channel, channel_group, NULL);
if (PNR_STARTED == rslt) {
p->trans = PBTT_SUBSCRIBE;
p->trans = PBTT_SUBSCRIBE;
p->core.last_result = PNR_STARTED;
pbnc_fsm(p);
rslt = p->core.last_result;
}

pubnub_mutex_unlock(p->monitor);
return rslt;
}



void pubnub_cancel(pubnub_t *pb)
void pubnub_cancel(pubnub_t* pb)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));

Expand All @@ -143,7 +149,7 @@ void pubnub_cancel(pubnub_t *pb)
}


void pubnub_set_uuid(pubnub_t *pb, const char *uuid)
void pubnub_set_uuid(pubnub_t* pb, const char* uuid)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
pubnub_mutex_lock(pb->monitor);
Expand All @@ -152,9 +158,9 @@ void pubnub_set_uuid(pubnub_t *pb, const char *uuid)
}


char const *pubnub_uuid_get(pubnub_t *pb)
char const* pubnub_uuid_get(pubnub_t* pb)
{
char const *result;
char const* result;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));

pubnub_mutex_lock(pb->monitor);
Expand All @@ -165,7 +171,7 @@ char const *pubnub_uuid_get(pubnub_t *pb)
}


void pubnub_set_auth(pubnub_t *pb, const char *auth)
void pubnub_set_auth(pubnub_t* pb, const char* auth)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
pubnub_mutex_lock(pb->monitor);
Expand All @@ -174,9 +180,9 @@ void pubnub_set_auth(pubnub_t *pb, const char *auth)
}


char const *pubnub_auth_get(pubnub_t *pb)
char const* pubnub_auth_get(pubnub_t* pb)
{
char const *result;
char const* result;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));

pubnub_mutex_lock(pb->monitor);
Expand All @@ -187,7 +193,7 @@ char const *pubnub_auth_get(pubnub_t *pb)
}


int pubnub_last_http_code(pubnub_t *pb)
int pubnub_last_http_code(pubnub_t* pb)
{
int result;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
Expand All @@ -198,9 +204,9 @@ int pubnub_last_http_code(pubnub_t *pb)
}


char const *pubnub_last_time_token(pubnub_t *pb)
char const* pubnub_last_time_token(pubnub_t* pb)
{
char const *result;
char const* result;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));

pubnub_mutex_lock(pb->monitor);
Expand All @@ -211,9 +217,9 @@ char const *pubnub_last_time_token(pubnub_t *pb)
}


static char const* do_last_publish_result(pubnub_t *pb)
static char const* do_last_publish_result(pubnub_t* pb)
{
char *end;
char* end;

if (PUBNUB_DYNAMIC_REPLY_BUFFER && (NULL == pb->core.http_reply)) {
return "";
Expand All @@ -236,7 +242,7 @@ static char const* do_last_publish_result(pubnub_t *pb)
}


char const *pubnub_last_publish_result(pubnub_t *pb)
char const* pubnub_last_publish_result(pubnub_t* pb)
{

char const* rslt;
Expand All @@ -250,11 +256,11 @@ char const *pubnub_last_publish_result(pubnub_t *pb)
}


char const *pubnub_get_origin(pubnub_t *pb)
char const* pubnub_get_origin(pubnub_t* pb)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
if (PUBNUB_ORIGIN_SETTABLE) {
char const *result;
char const* result;

pubnub_mutex_lock(pb->monitor);
result = pb->origin;
Expand All @@ -266,7 +272,7 @@ char const *pubnub_get_origin(pubnub_t *pb)
}


int pubnub_origin_set(pubnub_t *pb, char const *origin)
int pubnub_origin_set(pubnub_t* pb, char const* origin)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
if (PUBNUB_ORIGIN_SETTABLE) {
Expand Down
2 changes: 1 addition & 1 deletion core/pubnub_version_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define INC_PUBNUB_VERSION_INTERNAL


#define PUBNUB_SDK_VERSION "2.3.1"
#define PUBNUB_SDK_VERSION "2.3.2"


#endif /* !defined INC_PUBNUB_VERSION_INTERNAL */
3 changes: 0 additions & 3 deletions lib/sockets/pbpal_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ static int pal_init(void)

void pbpal_init(pubnub_t* pb)
{
if (PUBNUB_BLOCKING_IO_SETTABLE) {
pb->options.use_blocking_io = true;
}
pal_init();
pb->pal.socket = SOCKET_INVALID;
pb->sock_state = STATE_NONE;
Expand Down
1 change: 0 additions & 1 deletion openssl/pbpal_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ void pbpal_init(pubnub_t* pb)
{
pal_init();
memset(&pb->pal, 0, sizeof pb->pal);
pb->options.use_blocking_io = true;
pb->options.useSSL = pb->options.fallbackSSL = pb->options.ignoreSSL = true;
pb->options.use_system_certificate_store = false;
pb->options.reuse_SSL_session = true;
Expand Down
3 changes: 0 additions & 3 deletions openssl/pubnub_ntf_callback_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ int pbntf_got_socket(pubnub_t* pb, pb_socket_t sockt)
if (PUBNUB_TIMERS_API) {
m_watcher.timer_head = pubnub_timer_list_add(m_watcher.timer_head, pb);
}
pb->options.use_blocking_io = false;
pbpal_set_blocking_io(pb);

LeaveCriticalSection(&m_watcher.mutw);

return +1;
Expand Down
3 changes: 0 additions & 3 deletions posix/pubnub_ntf_callback_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ int pbntf_got_socket(pubnub_t* pb, pb_socket_t socket)
if (PUBNUB_TIMERS_API) {
m_watcher.timer_head = pubnub_timer_list_add(m_watcher.timer_head, pb);
}
pb->options.use_blocking_io = false;
pbpal_set_blocking_io(pb);

pthread_cond_signal(&m_watcher.condw);
pthread_mutex_unlock(&m_watcher.mutw);

Expand Down
2 changes: 0 additions & 2 deletions windows/pubnub_ntf_callback_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ int pbntf_got_socket(pubnub_t* pb, pb_socket_t sockt)
if (PUBNUB_TIMERS_API) {
m_watcher.timer_head = pubnub_timer_list_add(m_watcher.timer_head, pb);
}
pb->options.use_blocking_io = false;
pbpal_set_blocking_io(pb);

LeaveCriticalSection(&m_watcher.mutw);

Expand Down

0 comments on commit 7aa67d5

Please sign in to comment.