自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

eqxu的专栏

天使联盟

  • 博客(177)
  • 收藏
  • 关注

原创 查看linux被隐藏进程的内存占用方法,可用于监控进程是否内存泄漏

部分被隐藏的进程ps -aux Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.htmlUSER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMANDroot     17017  0.0  0

2011-12-22 09:44:45 4617 1

原创 如何察看当前服务器上的time_wait sock的多少

netstat -n |awk {print $6} |sort |uniq -c |sort -rn

2008-05-29 16:47:00 965

原创 如何减少TCP TIME_WAIT 套接字数量

net.ipv4.tcp_tw_reuse = 1   net.ipv4.tcp_tw_recycle = 1net.ipv4.ip_local_port_range = 1024    65000net.ipv4.tcp_max_tw_buckets = 30000 net.ipv4.tcp_tw_reuse = 1 表示开启重用。允许将TIME-WAIT sockets重新用于新的TC

2008-05-28 17:23:00 1570

原创 部分GNU代码片 19、快速的memcpy

#include stdio.h>#include stdlib.h>/**//* for small memory blocks (*/#define small_memcpy(to,from,n)...{register unsigned long int dummy;__asm__ __volatile__(  "rep; movsb"  :"=&D"(to), "=&S"(from),

2008-04-23 15:32:00 1294

原创 部分GNU代码片 18、字符串操作

size_t strlcat(        register char* s, register const char* t, register size_t n){    const char* o = t;        if (n)    {        while (--n && *s)            s++;        if (n)            do      

2008-04-22 21:00:00 736

原创 Understanding MySQL Internals 3:搭建环境

 Downloading with free client: Download the client if you have not already done so Download URL is http://www.bitmover.com/bk-client2.0.shar Unpack it and build it:

2008-04-15 16:34:00 1127

原创 Understanding MySQL Internals 2:模块图解

 

2008-04-13 12:25:00 2034

原创 Understanding MySQL Internals 1:学生应该如此这般的学习mysql

Good things happen when you push yourself outside of your comfort zone, doing what is difficult but what you know deep inside is the right thing to do. I wrote an email with a proposal to O’Reilly. 

2008-04-13 11:16:00 1353

原创 部分GNU代码片 17、GDB调试so的方法

许多服务器都使用了框架,那么如何调试so就成了问题1、假设我的可执行程序是ServerName,共享库为worker.so2、我用gdb调试ServerName,想在B的某个源文件(比如worker.cpp,worker.cpp与ServerName不在同一个目录下)中设置断点,使用下面的命令行break worker.cpp:123若找不到源文件可使用如下命令设定源文件目录:设定gd

2008-03-30 21:57:00 2254

原创 部分GNU代码片 16、GDB调试多线程的方法

#include #include #include #include #include #include void *print_message_function1(        void *ptr);void *print_message_function2(        void *ptr);int main(){    pthread_t thread1, thread2;    ch

2008-03-28 09:50:00 1017

原创 部分GNU代码片 15、GDB调试多进程的方法

 #include #include #include #include intmain (){        pid_t pid;        pid=fork();                if (pid                 printf("error in fork!");        else if (pid == 0)        {            i

2008-03-28 09:29:00 958

原创 部分GNU代码片 14、获取文件长度的两种方法 fopen open

pf = fopen(file, "r");    if (!pf)    {        cout        return FILE_OPEN_ERROR;    }    struct stat statBuf;    stat(file, &statBuf);        //如果是没有数据的"空文件",时间则为昨天    //否则,是文件记录的时间    cout       

2008-03-27 17:41:00 2189 1

原创 部分GNU代码片 13、函数中malloc内存,函数外用

#include #include #include using namespace std;struct sTest{    int a;    int b;};int ppfunc(sTest **pt){    *pt =(sTest *) malloc(32);    return 0;}int main(){    sTest *pt;    ppfunc(&pt);  

2008-03-27 15:06:00 861

原创 部分GNU代码片 12、给出年月日求天数

 long calc_daynr(uint year,uint month,uint day){  long delsum;  int temp;  if (year == 0 && month == 0 && day == 0)    DBUG_RETURN(0);             /* Skip errors */  if (year   {    if ((year=year

2008-03-26 21:26:00 652

原创 部分GNU代码片 11、合并文件

//合并文件static inline int Merge(const char* src_filename, const char* dst_filename){    int dst_fd = 0, src_fd = 0;    unsigned long long dst_size = 0, src_size = 0;    unsigned dst_count = 0, src_count

2008-03-19 17:37:00 625

原创 部分GNU代码片 10、二叉堆(Binary Heap)

n个关键字序列Kl,K2,…,Kn称为堆,当且仅当该序列满足如下性质(简称为堆性质):(1) a[i]≤a[i*2]且a[i]≤a[2*i+1] 或(2)a[i]≥a[i*2]且a[i]≥a[2*i+1](1≤i≤堆的元素个数  )struct binheap { unsigned  magic;#define BINHEAP_MAGIC  0xf581581aU /* from /dev/ran

2008-03-17 21:37:00 846

原创 部分GNU代码片 9、当前时间 精确到us

static inline double time_cost(void){#ifdef HAVE_CLOCK_GETTIME    struct timespec ts;        assert(clock_gettime(CLOCK_REALTIME, &ts) == 0);    return (ts.tv_sec + 1e-9 * ts.tv_nsec);#else    struct

2008-03-17 21:31:00 732

原创 部分GNU代码片 8、程序的配置文件解析部分辨别代码

    string argv1 = argc > 1 ? argv[1] : "";        stCFG ostCFG; //param struct    if (argc != 2)    {        cerr         exit(1);    }        if (argv1.find("--help") != string::npos)    {       

2008-03-16 22:26:00 665

原创 部分GNU代码片 7、mysql接口

//头文件#ifndef MYSQL_TOOL_H_#define MYSQL_TOOL_H_#include #include #include #include /** * /file Magic_Mysql.hh * /brief this file supplied common mysql access API. */  /**  * Magic_Mysql used

2008-03-16 22:24:00 790

原创 部分GNU代码片 6、split

/***************************************************************************** * @brief 函数find_keyword  * * 从data中获取参数key的值,data是以,作为分隔符 * @param data        原数据 * @param key         要查找的参数   * @par

2008-03-16 22:21:00 749

原创 部分GNU代码片 5、两个time_t之间的差(天、周、月)

//tEnd到tBegin的时间差 0 代表在同一个时间单位内、例如同一天、周、月static inline int getDaysSub(        time_t tBegin, time_t tItem){    return (tItem-tBegin)/86400;}static inline int getWeeksSub(        time_t tBegin, tim

2008-03-16 22:20:00 777

原创 部分GNU代码片 4、折半查找算法

//折半查找算法 /***************************************************************************** * @brief 函数binary_search  * 从items中查找key是不是存在 * @param items        原数据集合 * @param count      items的多少 * @para

2008-03-16 22:18:00 640

原创 部分GNU代码片 3、字符串2二维数组

  /***************************************************************************** * @brief 函数string2IntArray2D  *  1,2,3,;3,4,; * 从opt中获取参数 的列表放置到二纬数组中 * @param opt        原数据 * @param pArray    

2008-03-16 22:16:00 572

原创 部分GNU代码片 2、read_configfile

//读取配置文件的内容//获取配置文件的参数信息bool read_configfile(        char* configfile, stCFG &ostCFG){    FILE* f;    char line[256];        char* p=(char*)NULL;        int iFinish = 0;    if ((f = fopen(configfile

2008-03-16 22:15:00 683

原创 部分GNU代码片 1、trim

//去掉前后的空字符void trim_whitespace(        char* str){    //查找前面的空字符    char* p;    int i;    p=str;    for (i=0; isspace(p[i]); i++)        ;    //清除前面的空字符    for (; *p; p++)        *p=p[i];        p=str

2008-03-16 22:14:00 441

原创 window平台下编译GNU程序 例如:mysql操作的程序

要想在windows平台下编译GNU程序,需要有GNU的类库。现在有两种选择:1、mingw:轻量级的GNU库,有许多类库不能很好的支持2、cygwin:虚拟的linux运行平台,可以对linux的程序进行很全面的支持所以笔者选择cygwin平台,下面来介绍一下具体的操作方法:1、到cygwin.com网站下载cygwin的setup文件,运行生成一个如下目录E:/cygwin/h

2008-03-13 15:11:00 975

原创 linux C++ vector to array

unsigned char *aChar = 0;    std::vector vChar ;    vChar.push_back(0);    vChar.push_back(1);    vChar.push_back(2);    vChar.push_back(3);    vChar.push_back(4);    vChar.push_back(5);        aChar

2008-03-04 23:17:00 1581

原创 linux Debugger原理 工作流

  推荐google ptrace查看源码http://211.157.110.165/E-book_Video_Audio_Tutorial/20070216/964.pdf

2008-02-23 09:20:00 1417

原创 AJAX 服务端主动推送数据

comet是一种server push技术 功能使Request|Response类似于windows的消息处理机制 参考:http://www.ibm.com/developerworks/cn/web/wa-lo-comet/

2008-02-21 13:16:00 1319

原创 IT信息订阅 RSS源列表

 本人采用的是http://www.google.com/reader直接将下面的信息另存为xml文件,在reader中导入就可以了            Google 阅读器中 xu 的订阅                                            type="rss" xmlUrl="http://blog.csdn.net/rsspages/0.xml"

2008-02-20 21:24:00 11017

原创 eclipse NoSuchMethodError bug修正

 java.lang.NoSuchMethodError: java.net.URL: method getPath()Ljava/lang/String; not found 说明启动的时候path找不到java的bin目录所以要在path上设置好bin

2007-11-20 11:46:00 913

原创 multimap获取key列表

 1、首先调用find(K)获取以K开始的Iterator2、循环遍历        while (i != MultiMapName.end())        {            if ( smyKey != (*i).first )            {                break;            }            ……        } 

2007-10-17 13:28:00 3697

原创 apache源代码安装、配置

./configure --prefix=/usr/local/apache2make make install#启动/usr/local/apache2/bin/apachectl start|stop     ServerAdmin   [email protected]    DocumentRoot  /home/leolin/workspace/ads_ADMR    Sc

2007-09-29 10:00:00 666

原创 mysql的删除、安装步骤

mysql的卸载: 1 rpm -qa |grep mysql   rpm -e mysql* 2 到源代码所在目录 gmake uninstallmysql4.0.20的安装步骤:     shell> groupadd mysql     shell> useradd -g mysql mysql     shell> cd /usr/local     //shell> gunzip

2007-09-29 09:59:00 933

原创 在linux中查找包含了关键字的文件

find /etc -name * -exec cat {} /;|grep route add 查找包含了“route add” 关键字的在/etc目录下的文件 

2007-09-17 15:29:00 5642 1

原创 samba中加入用户

 1、useradd -m 用户名//系统中添加一个用户,并在/home目录下新建一个以用户名命名的文件夹2、passwd 用户名 //用来设置用户的密码3、smbpasswd -a 用户名//在samba中加入用户

2007-09-10 18:22:00 842

原创 C++编写的SO 并被调用过程

makefile:all: g++ map.cpp -o map.so -shared g++ main.cpp -o main -ldlclean: rm -rf main rm -rf map.so  map.cpp#include #include #include using namespace std;extern "C"{ void map(std::str

2007-08-31 10:41:00 1132

原创 自定义so的引用

1、在编译的时候用到了自定义的mapreduce库g++ -o prog -L. -lmapreduce main.cpp 2、ldd prog 可以查看出系统能不能找到你的mapreduce库3、如果查不到,有三种方法来解决这个问题    把库文件放到/usr/lib中    使用dlopen函数组    修改定义库文件所在目录的环境变量

2007-08-30 14:20:00 652

原创 so的Makefile.am的编写 Makefile的生成

Makefile.amAUTOMAKE_OPTIONS = foreignINCLUDES = -I.sbin_PROGRAMS = libmapreduce.so libmapreduce_so_SOURCES   =  map.cpp  libmapreduce.so: map.o  g++ -o libmapreduce.so -shared map.o map.o :map.cpp 

2007-08-30 14:16:00 3234 1

原创 查看程序运行失败后core文件给出的信息

1、如果没有core文件生成可以如下配置:  ulimit -c 结果可能是0;用ulimit   -c   unlimited命令开启2、 查看core文件给出的信息   #include int main() { char *p = NULL;         char *q = "123";         memcpy(p,q,4);     

2007-08-29 14:38:00 1466

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除