| 1064 | } |
| 1065 | |
| 1066 | static int process_user_msg(struct event_info *e) |
| 1067 | { |
| 1068 | net_send_message_header *msg = &e->msg; |
| 1069 | if (e->state == 0) { |
| 1070 | ++e->state; |
| 1071 | net_send_message_header_get(msg, e->rd_buf, e->rd_buf + sizeof(*msg)); |
| 1072 | if (msg->usertype <= USER_TYPE_MIN || msg->usertype >= USER_TYPE_MAX) { |
| 1073 | hprintf("BAD USER MSG TYPE:%d (htonl:%d)\n", msg->usertype, htonl(msg->usertype)); |
| 1074 | return -1; |
| 1075 | } |
| 1076 | if (msg->datalen) { |
| 1077 | e->need = msg->datalen; |
| 1078 | return 0; |
| 1079 | } |
| 1080 | } |
| 1081 | netinfo_type *netinfo_ptr = e->net_info->netinfo_ptr; |
| 1082 | NETFP *func = netinfo_ptr->userfuncs[msg->usertype].func; |
| 1083 | if (func == NULL) { |
| 1084 | /* Startup race without accept-on-child-net: Replication net is |
| 1085 | * ready and accepts offload connection but offload callbacks have not |
| 1086 | * registered yet. */ |
| 1087 | hprintf("NO USERFUNC FOR USERTYPE:%d\n", msg->usertype); |
| 1088 | return -1; |
| 1089 | } |
| 1090 | char *host = e->host; |
| 1091 | struct interned_string *host_interned = e->host_interned; |
| 1092 | |
| 1093 | void *usrptr = netinfo_ptr->usrptr; |
| 1094 | ack_state_type ack = { |
| 1095 | .seqnum = msg->seqnum, |
| 1096 | .needack = msg->waitforack, |
| 1097 | .fromhost = host, |
| 1098 | .netinfo = netinfo_ptr, |
| 1099 | }; |
| 1100 | func(&ack, usrptr, host, host_interned, msg->usertype, e->rd_buf, msg->datalen, 1); |
| 1101 | message_done(e); |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
| 1105 | static void stop_base(struct event_base *b) |
| 1106 | { |
no test coverage detected