缘起: 你提供了一批接口,很多使用方在调用,虽然每个调用方都有相应的标识,但是,存在这样一种情况,调用方自己都 …
分类存档:默认分类
tc的ulog文件解析及复制协议
1. 打开ulog文件
1308308 1308309 1308310 1308311 1308312 1308313 1308314 1308315 1308316 1308317 1308318 1308319 1308320 1308321 1308322 1308323 1308324 1308325 1308326 1308327 1308328 1308329 1308330 1308331 1308332 1308333 1308334 1308335 1308336 1308337 1308338 1308339 1308340 1308341 1308342 1308343 1308344 1308345 1308346 1308347 1308348 1308349 1308350 1308351 1308352 1308353 1308354 1308355 1308356 1308357 1308358 1308359 |
/* Create a log reader object. */ TCULRD *tculrdnew(TCULOG *ulog, uint64_t ts){ assert(ulog); if(!ulog->base) return NULL; if(pthread_rwlock_rdlock(&ulog->rwlck) != 0) return NULL; TCLIST *names = tcreaddir(ulog->base); if(!names){ pthread_rwlock_unlock(&ulog->rwlck); return NULL; } int ln = tclistnum(names); int max = 0; for(int i = 0; i < ln; i++){ const char *name = tclistval2(names, i); if(!tcstrbwm(name, TCULSUFFIX)) continue; int id = tcatoi(name); char *path = tcsprintf("%s/%08d%s", ulog->base, id, TCULSUFFIX); struct stat sbuf; if(stat(path, &sbuf) == 0 && S_ISREG(sbuf.st_mode) && id > max) max = id; tcfree(path); } tclistdel(names); if(max < 1) max = 1; uint64_t bts = (ts > TCULTMDEVALW * 1000000) ? ts - TCULTMDEVALW * 1000000 : 0; int num = 0; for(int i = max; i > 0; i--){ char *path = tcsprintf("%s/%08d%s", ulog->base, i, TCULSUFFIX); int fd = open(path, O_RDONLY, 00644); tcfree(path); if(fd == -1) break; int rsiz = sizeof(uint8_t) + sizeof(uint64_t); unsigned char buf[rsiz]; uint64_t fts = INT64_MAX; if(tcread(fd, buf, rsiz)){ memcpy(&fts, buf + sizeof(uint8_t), sizeof(ts)); fts = TTNTOHLL(fts); } close(fd); num = i; if(bts >= fts) break; } if(num < 1) num = 1; TCULRD *urld = tcmalloc(sizeof(*urld)); urld->ulog = ulog; urld->ts = ts; urld->num = num; urld->fd = -1; urld->rbuf = tcmalloc(TTIOBUFSIZ); urld->rsiz = TTIOBUFSIZ; pthread_rwlock_unlock(&ulog->rwlck); return urld; } |
2. 读取ulog …
关于数据报与字节流的理解
(1)定义差别[1] 数据报是网络传输的数据的基本单元,包含一个报头和数据本身,其中报头描述了数据的目的地以及 …
OSI 参考模块数据单元
数据报 [Datagram] 通过网络传输的数据的基本单元,包含一个报头(header)和数据本身,其中报头描 …
Unix Domain Socket的一些理解
1. unix域的数据报服务是否可靠 man unix 手册即可看到,unix domain socket 的 …
Unix Domain Socket使用遇到的一个问题
转自: http://www.cnblogs.com/skynet/archive/2010/12/04/18 …
关于北京车辆的两个网站
1. http://www.bjjtgl.gov.cn/ 北京市公安局公安交通管理局 (车辆违规记录查询) …
Apache中PHP脚本的默认的content-type
通过Apache 访问一个PHP文件,默认的content-type为 text/html , 如果通过PHP …
关于Memcache的使用
Memcache使用注意事项 慎重调整存储条目的大小 如何分析Memcache 的状态指标 evicted 能 …
关于rsyslog
1. rsyslog的tcp远程记录日志,如果远程主机端口宕掉,可以配置成先写本地文件队列,配置如下: [cr …