Skip to content

Commit

Permalink
fixed a segfault, fixed some double-reader requests
Browse files Browse the repository at this point in the history
  • Loading branch information
corsair committed Feb 17, 2012
1 parent f69537e commit c3f9406
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions module-cccam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,7 @@ int32_t cc_send_ecm(struct s_client *cl, ECM_REQUEST *er, uchar *buf) {

cur_er->rc = E_NOTFOUND;
cur_er->rcEx = E2_CCCAM_NOCARD;
write_ecm_answer(rdr, cur_er, E_NOTFOUND, E2_CCCAM_NOCARD, NULL,
NULL);
write_ecm_answer(rdr, cur_er, E_NOTFOUND, E2_CCCAM_NOCARD, NULL, NULL);
//cur_er->rc = 1;
//cur_er->rcEx = 0;
//cs_sleepms(300);
Expand Down Expand Up @@ -2880,7 +2879,7 @@ int32_t cc_recv(struct s_client *cl, uchar *buf, int32_t l) {

if (n <= 0) {
struct cc_data *cc = cl->cc;
if (cc->nok_message)
if (cc && cc->nok_message)
cs_log("%s connection closed by %s. Reason: %s", getprefix(), remote_txt(), cc->nok_message);
else
cs_log("%s connection closed by %s.", getprefix(), remote_txt());
Expand Down
1 change: 1 addition & 0 deletions module-datastruct-llist.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static void *ll_iter_next_nolock(LL_ITER *it)
if (!ptr) {
//it->cur = prvnxt;
ll_iter_reset(it); // restart iteration
it->cur = it->l->initial;
}
}
it->ll_version = it->l->version;
Expand Down
13 changes: 9 additions & 4 deletions oscam.c
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ int32_t write_ecm_answer(struct s_reader * reader, ECM_REQUEST *er, int8_t rc, u
if (er->parent) {
// parent is only set on reader->client->ecmtask[], but we want client->ecmtask[]
er->rc = rc;
//er->idx = 0;
er->idx = 0;
er = er->parent;
}

Expand Down Expand Up @@ -3634,8 +3634,11 @@ void * work_thread(void *ptr) {
if (reader)
data->action = ACTION_READER_REMOTE;
else {
if (cl->is_udp)
if (cl->is_udp) {
data->action = ACTION_CLIENT_UDP;
data->ptr = mbuf;
data->len = bufsize;
}
else
data->action = ACTION_CLIENT_TCP;
if (pfd[0].revents & (POLLHUP | POLLNVAL))
Expand Down Expand Up @@ -3744,11 +3747,13 @@ void * work_thread(void *ptr) {
case ACTION_CLIENT_UDP:
n = ph[cl->ctyp].recv(cl, data->ptr, data->len);
if (n<0) {
free(data->ptr);
if (data->ptr != mbuf)
free(data->ptr);
break;
}
ph[cl->ctyp].s_handler(cl, data->ptr, n);
free(data->ptr); // allocated in accept_connection()
if (data->ptr != mbuf)
free(data->ptr); // allocated in accept_connection()
break;
case ACTION_CLIENT_TCP:
s = check_fd_for_data(cl->pfd);
Expand Down

0 comments on commit c3f9406

Please sign in to comment.