Changeset 8668


Ignore:
Timestamp:
05/28/13 19:31:46 (9 years ago)
Author:
bowman
Message:

Skip push to csp if source is remote cacheex for now (might cause loops). Added sending of cache pings.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/module-cacheex.c

    r8666 r8668  
    160160        if (er->cacheex_src != cl) {
    161161            if (get_module(cl)->num == R_CSP) { // always send to csp cl
    162                 cacheex_cache_push_to_client(cl, er);
     162                if (!er->cacheex_src) cacheex_cache_push_to_client(cl, er); // but not if the origin was cacheex (might loop)
    163163            } else if (cl->typ == 'c' && !cl->dup && cl->account && cl->account->cacheex.mode == 2) { //send cache over user
    164164                if (get_module(cl)->c_cache_push // cache-push able
  • trunk/module-csp.c

    r8667 r8668  
    1414#include "oscam-net.h"
    1515#include "oscam-string.h"
     16#include "oscam-time.h"
    1617
    1718#define TYPE_REQUEST   1
     
    2324#define FAKE_ONID      0xFFFF
    2425#define FAKE_TAG       0x80
     26
     27#define PING_INTVL     4
    2528
    2629static void * csp_server(struct s_client *client __attribute__((unused)), uchar *mbuf __attribute__((unused)), int32_t n __attribute__((unused)))
     
    7780            break;
    7881
    79         case TYPE_REQUEST: // pending request hash received
     82        case TYPE_REQUEST: // pending request notification hash received
    8083            if (rs == 12) { // ignore requests for arbitration (csp "pre-requests", size 20)
    8184                uint16_t srvid = (buf[2] << 8) | buf[3];
     
    103106        case TYPE_PINGREQ:
    104107            if (rs == 13) {
     108                client->last = time((time_t*)0);
    105109                uint32_t port = b2i(4, buf + 9);
    106110                /*
     
    121125
    122126        case TYPE_PINGRPL:
    123             break;
    124 
    125         case TYPE_RESENDREQ:
     127            if (rs == 9) {
     128                struct timeb tpe;
     129                cs_ftime(&tpe);
     130                uint32_t ping = b2i(4, buf + 1);
     131                uint32_t now = tpe.time * 1000 + tpe.millitm;
     132                cs_debug_mask(D_TRACE, "received ping reply from cache peer: %s:%d (%d ms)", cs_inet_ntoa(SIN_GET_ADDR(client->udp_sa)), ntohs(SIN_GET_PORT(client->udp_sa)), now - ping);
     133            }
     134            break;
     135
     136        case TYPE_RESENDREQ: // sent as a result of delay alert in a remote cache
     137            if (rs == 16) {
     138                uint32_t port = b2i(4, buf + 1);
     139                // uint16_t caid = b2i(2, buf + 6);
     140                // uint32_t hash = b2i(4, buf + 8);
     141                cs_debug_mask(D_TRACE, "received resend request from cache peer: %s:%d", cs_inet_ntoa(SIN_GET_ADDR(client->udp_sa)), ntohs(port));
     142            }
    126143            break;
    127144
     
    131148
    132149    return rs;
     150}
     151
     152int32_t csp_send_ping(struct s_client *cl, uint32_t now)
     153{
     154    uchar buf[13] = {0};
     155   
     156    buf[0] = TYPE_PINGREQ;
     157    i2b_buf(4, now, buf + 1);
     158    i2b_buf(4, cfg.csp_port, buf + 9);
     159   
     160    int32_t status = sendto(cl->udp_fd, buf, sizeof(buf), 0, (struct sockaddr *)&cl->udp_sa, cl->udp_sa_len);
     161   
     162    cl->lastecm = time((time_t*)0);; // use this to indicate last ping sent for now
     163    return status;
    133164}
    134165
     
    143174            type = TYPE_REPLY;
    144175            break;
    145         case E_UNHANDLED: // request pending
     176        case E_UNHANDLED: // request pending - not yet used?
    146177            size = 12;
    147178            type = TYPE_REQUEST;
     
    171202        memcpy(buf + 13, er->cw, sizeof(er->cw));
    172203    }
     204   
     205    struct timeb tpe;
     206    cs_ftime(&tpe);
     207   
     208    if(tpe.time - cl->lastecm > PING_INTVL) csp_send_ping(cl, 1000 * tpe.time + tpe.millitm);
    173209
    174210    cs_ddump_mask(D_TRACE, buf, size, "pushing cache update to csp onid=%04X caid=%04X srvid=%04X hash=%08X (tag: %02X)", onid, er->caid, er->srvid, er->csp_hash, tag);
Note: See TracChangeset for help on using the changeset viewer.