static int print_to_pubnub_log(const char *s, size_t len, void *p) { PUBNUB_UNUSED(len); PUBNUB_UNUSED(p); PUBNUB_LOG_ERROR("%s", s); return 0; }
int pbntf_got_socket(pubnub_t *pb, pb_socket_t socket) { PUBNUB_UNUSED(socket); if (PUBNUB_BLOCKING_IO_SETTABLE) { pbpal_set_blocking_io(pb); } return +1; }
void test_runner(void *arg) { PUBNUB_UNUSED(arg); for (;;) { unsigned next_test = 0; unsigned failed_count = 0; unsigned passed_count = 0; unsigned indete_count = 0; unsigned tests_in_progress = 0; FreeRTOS_printf(("Starting Run of %d tests\n", TEST_COUNT)); while (failed_count + passed_count + indete_count < TEST_COUNT) { struct TestResultMessage msg; if ((tests_in_progress < g_max_conc_tests) && (next_test < TEST_COUNT)) { start_test(next_test++); ++tests_in_progress; } if (pdTRUE == xQueueReceive(m_TestResultQueue, &msg, pdMS_TO_TICKS(20))) { switch (msg.result) { case trFail: FreeRTOS_printf(("\n !!!!!!! The %d. test ('%s') failed!\n\n", msg.test + 1, m_aTest[msg.test].name)); ++failed_count; break; case trPass: ++passed_count; break; case trIndeterminate: ++indete_count; FreeRTOS_printf((" Indeterminate %d. test ('%s') of %d\t", msg.test+1, m_aTest[msg.test].name, TEST_COUNT)); /* Should restart the test... */ //FreeRTOS_printf((" ReStarting %d. test of %ld\t", msg.test + 1, TEST_COUNT)); break; } #ifdef INCLUDE_vTaskDelete vTaskDelete(m_aTest[msg.test].task); #endif --tests_in_progress; } } FreeRTOS_printf(("Test run over.\n")); if (passed_count == TEST_COUNT) { FreeRTOS_printf(("\n All %d tests passed\n", TEST_COUNT)); } else { FreeRTOS_printf(("\n\n %d tests passed, %d tests failed, %d tests indeterminate\n", passed_count, failed_count, indete_count )); } vTaskDelay(pdMS_TO_TICKS(10 * 1000)); } }
void pbntf_update_socket(pubnub_t *pb, pb_socket_t socket) { PUBNUB_UNUSED(socket); EnterCriticalSection(&m_watcher.mutw); update_socket(&m_watcher, pb); LeaveCriticalSection(&m_watcher.mutw); }
void pbntf_lost_socket(pubnub_t *pb, pb_socket_t socket) { PUBNUB_UNUSED(socket); if (pdFALSE == xSemaphoreTakeRecursive(m_watcher.mutw, TICKS_TO_WAIT)) { return ; } remove_socket(&m_watcher, pb); remove_timer_safe(pb); xSemaphoreGiveRecursive(m_watcher.mutw); xTaskNotifyGive(m_watcher.task); }
enum pbpal_resolv_n_connect_result pbpal_check_resolv_and_connect(pubnub_t *pb) { #ifdef PUBNUB_CALLBACK_API struct sockaddr_in dns_server; struct sockaddr_in dest; uint16_t port = HTTP_PORT; pbpal_native_socket_t skt; PUBNUB_ASSERT(pb_valid_ctx_ptr(pb)); PUBNUB_ASSERT_OPT(pb->state == PBS_WAIT_DNS_RCV); #if PUBNUB_USE_SSL if (pb->flags.trySSL) { PUBNUB_ASSERT(pb->options.useSSL); port = TLS_PORT; } #endif #if PUBNUB_PROXY_API if (pbproxyNONE != pb->proxy_type) { port = pb->proxy_port; } #endif skt = pb->pal.socket; PUBNUB_ASSERT(SOCKET_INVALID != skt); dns_server.sin_family = AF_INET; dns_server.sin_port = htons(DNS_PORT); get_dns_ip(&dns_server); memset(&dest, '\0', sizeof dest); switch (read_dns_response(skt, (struct sockaddr*)&dns_server, &dest)) { case -1: return pbpal_resolv_failed_rcv; case +1: return pbpal_resolv_rcv_wouldblock; case 0: break; } socket_close(skt); return connect_TCP_socket(pb, dest, port); #else PUBNUB_UNUSED(pb); /* Under regular BSD-ish sockets, this function should not be called unless using async DNS, so this is an error */ return pbpal_connect_failed; #endif /* PUBNUB_CALLBACK_API */ }
int pbntf_got_socket(pubnub_t *pb, pb_socket_t socket) { PUBNUB_UNUSED(socket); if (pdFALSE == xSemaphoreTakeRecursive(m_watcher.mutw, TICKS_TO_WAIT)) { return -1; } save_socket(&m_watcher, pb); if (PUBNUB_TIMERS_API) { m_watcher.timer_head = pubnub_timer_list_add(m_watcher.timer_head, pb); } xSemaphoreGiveRecursive(m_watcher.mutw); xTaskNotifyGive(m_watcher.task); return +1; }
void pbntf_lost_socket(pubnub_t *pb, pb_socket_t socket) { PUBNUB_UNUSED(socket); PUBNUB_UNUSED(pb); }
void pbpal_forget(pubnub_t *pb) { /* `socket_close` pretty much means "forget" in BSD-ish sockets */ PUBNUB_UNUSED(pb); }
int pbntf_requeue_for_processing(pubnub_t *pb) { PUBNUB_UNUSED(pb); return 0; }
int pbntf_watch_out_events(pubnub_t* pbp) { PUBNUB_UNUSED(pbp); return 0; }
void pbntf_lost_socket(pubnub_t* pb) { PUBNUB_UNUSED(pb); }
void pbntf_update_socket(pubnub_t* pb) { PUBNUB_UNUSED(pb); }
void pbntf_lost_socket(pubnub_t *pb, pb_socket_t socket) { PUBNUB_UNUSED(socket); remove_socket(&m_watcher, pb); remove_timer_safe(pb); }
void pbntf_update_socket(pubnub_t *pb, pb_socket_t socket) { /* We don't care. */ PUBNUB_UNUSED(pb); PUBNUB_UNUSED(socket); }