对于同一个文件,虽然每次读写的数据量很小,但是如果每次读写的位置很随机,那么读写的效率也是很低的,大家都知道。 …
分类存档:默认分类
关于i18n
$ gettext -d coreutils total
bash 基础
http://man.cx/bash(1)/zh_cn 一些小的知识点: ‘(‘,& …
在线考试系统
http://down.chinaz.com/test/201108/976_2.htm &nb …
wordpress 的视频插件
wordpress 的视频插件 http://wordpress.org/extend/plug …
Keeping your SSH sessions alive with NOOP
你在使用secureCRT的时候,会不会一段时间没有动作的就断开?没有就算了,有就看图:
关于strace
strace是用来跟踪系统调用的,这里只研究一个问题: 在一个系统调用返回之前,系统调用的参数是否会被显示出来 …
who call me?
缘起: 你提供了一批接口,很多使用方在调用,虽然每个调用方都有相应的标识,但是,存在这样一种情况,调用方自己都 …
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] 数据报是网络传输的数据的基本单元,包含一个报头和数据本身,其中报头描述了数据的目的地以及 …