本文整理汇总了C++中THREAD_ARG函数的典型用法代码示例。如果您正苦于以下问题:C++ THREAD_ARG函数的具体用法?C++ THREAD_ARG怎么用?C++ THREAD_ARG使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了THREAD_ARG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bgp_keepalive_timer
/* BGP keepalive fire ! */
static int
bgp_keepalive_timer (struct thread *thread)
{
struct peer *peer;
peer = THREAD_ARG (thread);
peer->t_keepalive = NULL;
if (BGP_DEBUG (fsm, FSM))
zlog (peer->log, LOG_DEBUG,
"%s [FSM] Timer (keepalive timer expire)",
peer->host);
THREAD_VAL (thread) = KeepAlive_timer_expired;
bgp_event (thread); /* bgp_event unlocks peer */
return 0;
}
示例2: ospf_hello_timer
int ospf_hello_timer(struct thread *thread)
{
struct ospf_interface *oi;
oi = THREAD_ARG(thread);
oi->t_hello = NULL;
if (IS_DEBUG_OSPF(ism, ISM_TIMERS))
zlog(NULL, LOG_DEBUG, "ISM[%s]: Timer (Hello timer expire)",
IF_NAME(oi));
/* Sending hello packet. */
ospf_hello_send(oi);
/* Hello timer set. */
OSPF_HELLO_TIMER_ON(oi);
return 0;
}
示例3: isis_adj_expire
int
isis_adj_expire (struct thread *thread)
{
struct isis_adjacency *adj;
int level;
/*
* Get the adjacency
*/
adj = THREAD_ARG (thread);
assert (adj);
level = adj->level;
adj->t_expire = NULL;
/* trigger the adj expire event */
isis_adj_state_change (adj, ISIS_ADJ_DOWN, "holding time expired");
return 0;
}
示例4: ospf6_bfd_down
int
ospf6_bfd_down (struct thread *thread)
{
struct ospf6_neighbor *on;
on = (struct ospf6_neighbor *) THREAD_ARG (thread);
assert (on);
if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
zlog_info ("Neighbor Event %s: *BFD Down*", on->name);
on->drouter = on->prev_drouter = 0;
on->bdrouter = on->prev_bdrouter = 0;
ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on);
thread_add_event (master, neighbor_change, on->ospf6_if, 0);
return 0;
}
示例5: hello_received
int hello_received(struct thread * thread)
{
struct ospf6_neighbor * on;
on = THREAD_ARG(thread);
assert(on);
printf("Hello Received\n");
/* reset Inactivity Timer */
THREAD_OFF (on->inactivity_timer);
on->inactivity_timer = thread_add_timer (master, inactivity_timer, on,
on->ospf6_if->dead_interval);
if(on->state <= OSPF6_NEIGHBOR_DOWN)
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on);
return 0;
}
示例6: bgp_event
/* Execute event process. */
int
bgp_event (struct thread *thread)
{
int ret = 0;
int event;
int next;
struct peer *peer;
peer = THREAD_ARG (thread);
event = THREAD_VAL (thread);
/* Logging this event. */
next = FSM [peer->status -1][event - 1].next_state;
if (BGP_DEBUG (fsm, FSM) && peer->status != next)
plog_debug (peer->log, "%s [FSM] %s (%s->%s)", peer->host,
bgp_event_str[event],
LOOKUP (bgp_status_msg, peer->status),
LOOKUP (bgp_status_msg, next));
/* Call function. */
if (FSM [peer->status -1][event - 1].func)
ret = (*(FSM [peer->status - 1][event - 1].func))(peer);
/* When function do not want proceed next job return -1. */
if (ret >= 0)
{
/* If status is changed. */
if (next != peer->status)
{
/* Transition into Clearing must /always/ clear all routes.. */
if (next == Clearing)
bgp_clear_route_all (peer);
bgp_fsm_change_status (peer, next);
}
/* Make sure timer is set. */
bgp_timer_set (peer);
}
return ret;
}
示例7: neighbor_change
int
neighbor_change (struct thread *thread)
{
struct ospf6_interface *oi;
oi = (struct ospf6_interface *) THREAD_ARG (thread);
assert (oi && oi->interface);
if (IS_OSPF6_DEBUG_INTERFACE)
zlog_debug ("Interface Event %s: [NeighborChange]",
oi->interface->name);
if (oi->state == OSPF6_INTERFACE_DROTHER ||
oi->state == OSPF6_INTERFACE_BDR ||
oi->state == OSPF6_INTERFACE_DR)
ospf6_interface_state_change (dr_election (oi), oi);
return 0;
}
示例8: bgp_start_timer
/* BGP start timer. This function set BGP_Start event to thread value
and process event. */
static int
bgp_start_timer (struct thread *thread)
{
struct peer *peer;
peer = THREAD_ARG (thread);
peer->t_start = NULL;
UNSET_FLAG (peer->sflags, PEER_STATUS_CREATE_INIT);
if (BGP_DEBUG (fsm, FSM))
zlog (peer->log, LOG_DEBUG,
"%s [FSM] Timer (start timer expire).", peer->host);
THREAD_VAL (thread) = BGP_Start;
bgp_event (thread);
return 0;
}
示例9: hello_low_send
//周期性发送hello low数据包
int hello_low_send(struct thread * thread)
{
struct backbone_eth* eth = (struct backbone_eth *)THREAD_ARG(thread);
struct hello_low* hello_low = (struct hello_low*)sendbuf;
struct hello_master* hello_master = eth->hello_master;
hello_master->hello_timer_low = thread_add_timer_high_resolution(master, hello_low_send, eth, TMP_VAR * hello_master->l_hello_val);
memset(sendbuf, 0, MAX_MESSAGE_LEN);
hello_low->lsd_head.pktype = IC_MESSAGE_TYPE_HELLO_L;
hello_low->lsd_head.pklen = sizeof(struct hello_low);
hello_low->dead_interval = TMP_VAR * hello_master->l_dead_val;
hello_low->hello_interval = TMP_VAR * hello_master->l_hello_val;
lsd_send(eth, (struct lsd_head *)sendbuf);
return 0;
}
示例10: tcp_socket_state
enum connect_result
tcp_socket_state(int fd, thread_t * thread, int (*func) (thread_t *))
{
int status;
socklen_t addrlen;
int ret = 0;
timeval_t timer_min;
/* Handle connection timeout */
if (thread->type == THREAD_WRITE_TIMEOUT) {
close(thread->u.fd);
return connect_timeout;
}
/* Check file descriptor */
addrlen = sizeof(status);
if (getsockopt(thread->u.fd, SOL_SOCKET, SO_ERROR, (void *) &status, &addrlen) < 0)
ret = errno;
/* Connection failed !!! */
if (ret) {
close(thread->u.fd);
return connect_error;
}
/* If status = 0, TCP connection to remote host is established.
* Otherwise register checker thread to handle connection in progress,
* and other error code until connection is established.
* Recompute the write timeout (or pending connection).
*/
if (status == EINPROGRESS) {
timer_min = timer_sub_now(thread->sands);
thread_add_write(thread->master, func, THREAD_ARG(thread),
thread->u.fd, timer_long(timer_min));
return connect_in_progress;
} else if (status != 0) {
close(thread->u.fd);
return connect_error;
}
return connect_success;
}
示例11: bgp_event
/* Execute event process. */
int
bgp_event (struct thread *thread)
{
int ret;
int event;
int next;
struct peer *peer;
peer = THREAD_ARG (thread);
event = THREAD_VAL (thread);
/* Logging this event. */
next = FSM [peer->status -1][event - 1].next_state;
if (BGP_DEBUG (fsm, FSM))
plog_info (peer->log, "%s [FSM] %s (%s->%s)", peer->host,
bgp_event_str[event],
LOOKUP (bgp_status_msg, peer->status),
LOOKUP (bgp_status_msg, next));
if (BGP_DEBUG (normal, NORMAL)
&& strcmp (LOOKUP (bgp_status_msg, peer->status), LOOKUP (bgp_status_msg, next)))
zlog_info ("%s went from %s to %s",
peer->host,
LOOKUP (bgp_status_msg, peer->status),
LOOKUP (bgp_status_msg, next));
/* Call function. */
ret = (*(FSM [peer->status - 1][event - 1].func))(peer);
/* When function do not want proceed next job return -1. */
if (ret < 0)
return ret;
/* If status is changed. */
if (next != peer->status)
bgp_fsm_change_status (peer, next);
/* Make sure timer is set. */
bgp_timer_set (peer);
return 0;
}
示例12: http_read_thread
/* Asynchronous HTTP stream reader */
int
http_read_thread(thread_t * thread)
{
SOCK *sock_obj = THREAD_ARG(thread);
int r = 0;
/* Handle read timeout */
if (thread->type == THREAD_READ_TIMEOUT)
return epilog(thread);
/* read the HTTP stream */
memset(sock_obj->buffer, 0, MAX_BUFFER_LENGTH);
r = read(thread->u.fd, sock_obj->buffer + sock_obj->size,
MAX_BUFFER_LENGTH - sock_obj->size);
DBG(" [l:%d,fd:%d]\n", r, sock_obj->fd);
if (r == -1 || r == 0) { /* -1:error , 0:EOF */
if (r == -1) {
/* We have encourred a real read error */
DBG("Read error with server [%s]:%d: %s\n",
inet_ntop2(req->addr_ip), ntohs(req->addr_port),
strerror(errno));
return epilog(thread);
}
/* All the HTTP stream has been parsed */
finalize(thread);
} else {
/* Handle the response stream */
http_process_stream(sock_obj, r);
/*
* Register next http stream reader.
* Register itself to not perturbe global I/O multiplexer.
*/
thread_add_read(thread->master, http_read_thread, sock_obj,
thread->u.fd, HTTP_CNX_TIMEOUT);
}
return 0;
}
示例13: rcpt_cmd
/* RCPT command processing */
static int
rcpt_cmd(thread_t * thread)
{
smtp_t *smtp = THREAD_ARG(thread);
char *buffer;
char *fetched_email;
buffer = (char *) MALLOC(SMTP_BUFFER_MAX);
/* We send RCPT TO command multiple time to add all our email receivers.
* --rfc821.3.1
*/
fetched_email = fetch_next_email(smtp);
snprintf(buffer, SMTP_BUFFER_MAX, SMTP_RCPT_CMD, fetched_email);
if (send(thread->u.fd, buffer, strlen(buffer), 0) == -1)
smtp->stage = ERROR;
FREE(buffer);
return 0;
}
示例14: lsa_delete
static int
lsa_delete (struct thread *t)
{
struct ospf_apiclient *oclient;
struct in_addr area_id;
int rc;
oclient = THREAD_ARG (t);
inet_aton (args[6], &area_id);
printf ("Deleting LSA... ");
rc = ospf_apiclient_lsa_delete (oclient,
area_id,
atoi (args[2]), /* lsa type */
atoi (args[3]), /* opaque type */
atoi (args[4])); /* opaque ID */
printf ("done, return code is = %d\n", rc);
return rc;
}
示例15: loading_done
int
loading_done (struct thread *thread)
{
struct ospf6_neighbor *on;
on = (struct ospf6_neighbor *) THREAD_ARG (thread);
assert (on);
if (on->state != OSPF6_NEIGHBOR_LOADING)
return 0;
if (IS_OSPF6_SIBLING_DEBUG_NEIGHBOR)
zlog_debug ("Neighbor Event %s: *LoadingDone*", on->name);
assert (on->request_list->count == 0);
ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
return 0;
}