static void *thr_channel_snder(void *ptr) { struct mlib_listentry_st *ent = ptr; int len; struct msg_channel_st *sbufp; int datasize; sbufp = malloc(MSG_CHANNEL_MAX); if (sbufp == NULL) { syslog(LOG_ERR, "malloc(): %m"); exit(1); } datasize = MSG_CHANNEL_MAX - sizeof(chnid_t); sbufp->id = ent->id; while (1) { pthread_testcancel(); len = mlib_readchn(ent->id, sbufp->data, datasize); sendto(serversd, sbufp, len + sizeof(chnid_t), 0, (void *)&sndaddr, sizeof(sndaddr)); sched_yield(); } }
static void* thr_channel_snder(void* ptr){ struct mlib_listentry_st *ent = (mlib_listentry_st*)ptr; char buf[BUFSIZE]; int len, ret; struct msg_channel_st* sbufp; int datasize; syslog(LOG_DEBUG, "thr_channel_snder() is working for channel %d", ent->id); sbufp = (msg_channel_st*)malloc(MSG_CHANNEL_MAX); if(sbufp == NULL){ syslog(LOG_ERR, "malloc(): %s",strerror(errno)); exit(1); } datasize = MSG_CHANNEL_MAX-sizeof(chnid_t); sbufp->id = ent->id; while(1){ //pthread_testcancel(); len = mlib_readchn(ent->id, sbufp->data, datasize); //sbuf->xxx = xxx; sendto(serversd, sbufp, len+sizeof(chnid_t), 0, (const sockaddr*)&sndaddr, sizeof(sndaddr)); //ret = write(1, buf, len); //fprintf(stderr, "%d bytes sent.\n", ret); //sched_yield(); } }