Skip to content

Commit

Permalink
Fix high cpu usage when CAM not plugged in for enigma #1096
Browse files Browse the repository at this point in the history
  • Loading branch information
Catalin Toda committed May 31, 2023
1 parent d968ac2 commit b233de6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -1727,10 +1727,10 @@ static int CIPLUS_APP_LANG_handler(ca_session_t *session, int tag,
// if (data_length)
// hexdump(data, data_length);

uint8_t data_reply_lang[3]; // ISO 639 Part 2
data_reply_lang[0] = 0x65; /* e */
data_reply_lang[1] = 0x6e; /* n */
data_reply_lang[2] = 0x67; /* g */
uint8_t data_reply_lang[3]; // ISO 639 Part 2
data_reply_lang[0] = 0x65; /* e */
data_reply_lang[1] = 0x6e; /* n */
data_reply_lang[2] = 0x67; /* g */

uint8_t data_reply_country[3]; // ISO 3166-1 alpha 3
data_reply_country[0] = 0x55; /* U */
Expand Down Expand Up @@ -2703,6 +2703,17 @@ int ca_read_enigma(int socket, void *buf, int len, sockets *ss, int *rb) {
*rb = 0;
if (rl > 0) {
*rb = rl;
if (ss->events & ~POLLPRI) {
ss->events |= POLLPRI;
}
return 1;
}
if (ss->revents == POLLPRI) {
ca_device_t *d = ca_devices[ss->sid];
if (d->state != CA_STATE_INACTIVE) {
d->state = CA_STATE_INACTIVE;
}
ss->events = POLLIN;
}
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/pmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ int process_sdt(int filter, unsigned char *sdt, int len, void *opaque) {
set_filter_flags(filter, FILTER_PERMANENT | FILTER_REVERSE | FILTER_CRC);
sdt_len = (sdt[1] & 0xF) * 256 + sdt[2];
i = 11;
LOGM("Processing SDT for transponder %d (%x) with length %d, sdt[5] "
DEBUGM("Processing SDT for transponder %d (%x) with length %d, sdt[5] "
"%02X",
tsid, tsid, sdt_len, sdt[5]);

Expand All @@ -2183,7 +2183,7 @@ int process_sdt(int filter, unsigned char *sdt, int len, void *opaque) {
desc_loop_len = (b[3] & 0xF) * 256 + b[4];
desc_loop_len += 5;
pmt = get_all_pmt_for_sid(ad->id, sid);
LOGM("Detected service ID %d (%X) status:%d CA:%d, pos %d len %d", sid,
DEBUGM("Detected service ID %d (%X) status:%d CA:%d, pos %d len %d", sid,
sid, (status >> 1), (status & 0x1), i, desc_loop_len);
if (!pmt) {
LOG("%s: no PMT found for sid %d (%X)", __FUNCTION__, sid, sid);
Expand Down

0 comments on commit b233de6

Please sign in to comment.