-
Notifications
You must be signed in to change notification settings - Fork 36
/
co_hook_sys_call.cpp
712 lines (592 loc) · 16.9 KB
/
co_hook_sys_call.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
/*
* Tencent is pleased to support the open source community by making Libco available.
* Copyright (C) 2014 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/syscall.h>
#include <sys/un.h>
#include <dlfcn.h>
#include <poll.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <errno.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <pthread.h>
#include <time.h>
#include "co_routine.h"
#include "co_routine_inner.h"
typedef long long ll64_t;
struct rpchook_t
{
int user_flag;
struct sockaddr_in dest; //maybe sockaddr_un;
int domain; //AF_LOCAL , AF_INET
struct timeval read_timeout;
struct timeval write_timeout;
};
static inline pid_t GetPid()
{
char **p = (char**)pthread_self();
return p ? *(pid_t*)(p + 18) : getpid();
}
static rpchook_t *g_rpchook_socket_fd[ 102400 ] = { 0 };
typedef int (*socket_pfn_t)(int domain, int type, int protocol);
typedef int (*connect_pfn_t)(int socket, const struct sockaddr *address, socklen_t address_len);
typedef int (*close_pfn_t)(int fd);
typedef ssize_t (*read_pfn_t)(int fildes, void *buf, size_t nbyte);
typedef ssize_t (*write_pfn_t)(int fildes, const void *buf, size_t nbyte);
typedef ssize_t (*sendto_pfn_t)(int socket, const void *message, size_t length,
int flags, const struct sockaddr *dest_addr,
socklen_t dest_len);
typedef ssize_t (*recvfrom_pfn_t)(int socket, void *buffer, size_t length,
int flags, struct sockaddr *address,
socklen_t *address_len);
typedef size_t (*send_pfn_t)(int socket, const void *buffer, size_t length, int flags);
typedef ssize_t (*recv_pfn_t)(int socket, void *buffer, size_t length, int flags);
typedef int (*poll_pfn_t)(struct pollfd fds[], nfds_t nfds, int timeout);
typedef int (*setsockopt_pfn_t)(int socket, int level, int option_name,
const void *option_value, socklen_t option_len);
typedef int (*fcntl_pfn_t)(int fildes, int cmd, ...);
typedef struct tm *(*localtime_r_pfn_t)( const time_t *timep, struct tm *result );
typedef void *(*pthread_getspecific_pfn_t)(pthread_key_t key);
typedef int (*pthread_setspecific_pfn_t)(pthread_key_t key, const void *value);
typedef int (*pthread_rwlock_rdlock_pfn_t)(pthread_rwlock_t *rwlock);
typedef int (*pthread_rwlock_wrlock_pfn_t)(pthread_rwlock_t *rwlock);
typedef int (*pthread_rwlock_unlock_pfn_t)(pthread_rwlock_t *rwlock);
static socket_pfn_t g_sys_socket_func = (socket_pfn_t)dlsym(RTLD_NEXT,"socket");
static connect_pfn_t g_sys_connect_func = (connect_pfn_t)dlsym(RTLD_NEXT,"connect");
static close_pfn_t g_sys_close_func = (close_pfn_t)dlsym(RTLD_NEXT,"close");
static read_pfn_t g_sys_read_func = (read_pfn_t)dlsym(RTLD_NEXT,"read");
static write_pfn_t g_sys_write_func = (write_pfn_t)dlsym(RTLD_NEXT,"write");
static sendto_pfn_t g_sys_sendto_func = (sendto_pfn_t)dlsym(RTLD_NEXT,"sendto");
static recvfrom_pfn_t g_sys_recvfrom_func = (recvfrom_pfn_t)dlsym(RTLD_NEXT,"recvfrom");
static send_pfn_t g_sys_send_func = (send_pfn_t)dlsym(RTLD_NEXT,"send");
static recv_pfn_t g_sys_recv_func = (recv_pfn_t)dlsym(RTLD_NEXT,"recv");
static poll_pfn_t g_sys_poll_func = (poll_pfn_t)dlsym(RTLD_NEXT,"poll");
static setsockopt_pfn_t g_sys_setsockopt_func
= (setsockopt_pfn_t)dlsym(RTLD_NEXT,"setsockopt");
static fcntl_pfn_t g_sys_fcntl_func = (fcntl_pfn_t)dlsym(RTLD_NEXT,"fcntl");
/*
static pthread_getspecific_pfn_t g_sys_pthread_getspecific_func
= (pthread_getspecific_pfn_t)dlsym(RTLD_NEXT,"pthread_getspecific");
static pthread_setspecific_pfn_t g_sys_pthread_setspecific_func
= (pthread_setspecific_pfn_t)dlsym(RTLD_NEXT,"pthread_setspecific");
static pthread_rwlock_rdlock_pfn_t g_sys_pthread_rwlock_rdlock_func
= (pthread_rwlock_rdlock_pfn_t)dlsym(RTLD_NEXT,"pthread_rwlock_rdlock");
static pthread_rwlock_wrlock_pfn_t g_sys_pthread_rwlock_wrlock_func
= (pthread_rwlock_wrlock_pfn_t)dlsym(RTLD_NEXT,"pthread_rwlock_wrlock");
static pthread_rwlock_unlock_pfn_t g_sys_pthread_rwlock_unlock_func
= (pthread_rwlock_unlock_pfn_t)dlsym(RTLD_NEXT,"pthread_rwlock_unlock");
*/
static inline unsigned long long get_tick_count()
{
uint32_t lo, hi;
__asm__ __volatile__ (
"rdtscp" : "=a"(lo), "=d"(hi)
);
return ((unsigned long long)lo) | (((unsigned long long)hi) << 32);
}
struct rpchook_connagent_head_t
{
unsigned char bVersion;
struct in_addr iIP;
unsigned short hPort;
unsigned int iBodyLen;
unsigned int iOssAttrID;
unsigned char bIsRespNotExist;
unsigned char sReserved[6];
}__attribute__((packed));
#define HOOK_SYS_FUNC(name) if( !g_sys_##name##_func ) { g_sys_##name##_func = (name##_pfn_t)dlsym(RTLD_NEXT,#name); }
static inline ll64_t diff_ms(struct timeval &begin,struct timeval &end)
{
ll64_t u = (end.tv_sec - begin.tv_sec) ;
u *= 1000 * 10;
u += ( end.tv_usec - begin.tv_usec ) / ( 100 );
return u;
}
static inline rpchook_t * get_by_fd( int fd )
{
if( fd > -1 && fd < (int)sizeof(g_rpchook_socket_fd) / (int)sizeof(g_rpchook_socket_fd[0]) )
{
return g_rpchook_socket_fd[ fd ];
}
return NULL;
}
static inline rpchook_t * alloc_by_fd( int fd )
{
if( fd > -1 && fd < (int)sizeof(g_rpchook_socket_fd) / (int)sizeof(g_rpchook_socket_fd[0]) )
{
rpchook_t *lp = (rpchook_t*)calloc( 1,sizeof(rpchook_t) );
lp->read_timeout.tv_sec = 1;
lp->write_timeout.tv_sec = 1;
g_rpchook_socket_fd[ fd ] = lp;
return lp;
}
return NULL;
}
static inline void free_by_fd( int fd )
{
if( fd > -1 && fd < (int)sizeof(g_rpchook_socket_fd) / (int)sizeof(g_rpchook_socket_fd[0]) )
{
rpchook_t *lp = g_rpchook_socket_fd[ fd ];
if( lp )
{
g_rpchook_socket_fd[ fd ] = NULL;
free(lp);
}
}
return;
}
int socket(int domain, int type, int protocol)
{
HOOK_SYS_FUNC( socket );
if( !co_is_enable_sys_hook() )
{
return g_sys_socket_func( domain,type,protocol );
}
int fd = g_sys_socket_func(domain,type,protocol);
if( fd < 0 )
{
return fd;
}
rpchook_t *lp = alloc_by_fd( fd );
lp->domain = domain;
fcntl( fd, F_SETFL, g_sys_fcntl_func(fd, F_GETFL,0 ) );
return fd;
}
int co_accept( int fd, struct sockaddr *addr, socklen_t *len )
{
int cli = accept( fd,addr,len );
if( cli < 0 )
{
return cli;
}
//rpchook_t *lp = alloc_by_fd( cli );
return cli;
}
int connect(int fd, const struct sockaddr *address, socklen_t address_len)
{
HOOK_SYS_FUNC( connect );
if( !co_is_enable_sys_hook() )
{
return g_sys_connect_func(fd,address,address_len);
}
int ret = g_sys_connect_func(fd,address,address_len);
if( address_len == sizeof(sockaddr_un))
{
const struct sockaddr_un *p = (const struct sockaddr_un *)address;
if( strstr( p->sun_path,"connagent_unix_domain_socket") ) ///tmp/connagent_unix_domain_socket
{
}
}
rpchook_t *lp = get_by_fd( fd );
if( lp )
{
if( sizeof(lp->dest) >= address_len )
{
memcpy( &(lp->dest),address,(int)address_len );
}
}
return ret;
}
int close(int fd)
{
HOOK_SYS_FUNC( close );
if( !co_is_enable_sys_hook() )
{
return g_sys_close_func( fd );
}
free_by_fd( fd );
int ret = g_sys_close_func(fd);
return ret;
}
ssize_t read( int fd, void *buf, size_t nbyte )
{
HOOK_SYS_FUNC( read );
if( !co_is_enable_sys_hook() )
{
return g_sys_read_func( fd,buf,nbyte );
}
rpchook_t *lp = get_by_fd( fd );
if( !lp || ( O_NONBLOCK & lp->user_flag ) )
{
ssize_t ret = g_sys_read_func( fd,buf,nbyte );
return ret;
}
int timeout = ( lp->read_timeout.tv_sec * 1000 )
+ ( lp->read_timeout.tv_usec / 1000 );
struct pollfd pf = { 0 };
pf.fd = fd;
pf.events = ( POLLIN | POLLERR | POLLHUP );
int pollret = poll( &pf,1,timeout );
ssize_t readret = g_sys_read_func( fd,(char*)buf ,nbyte );
if( readret < 0 )
{
co_log_err("CO_ERR: read fd %d ret %ld errno %d poll ret %d timeout %d",
fd,readret,errno,pollret,timeout);
}
return readret;
}
ssize_t write( int fd, const void *buf, size_t nbyte )
{
HOOK_SYS_FUNC( write );
if( !co_is_enable_sys_hook() )
{
return g_sys_write_func( fd,buf,nbyte );
}
rpchook_t *lp = get_by_fd( fd );
if( !lp || ( O_NONBLOCK & lp->user_flag ) )
{
ssize_t ret = g_sys_write_func( fd,buf,nbyte );
return ret;
}
size_t wrotelen = 0;
int timeout = ( lp->write_timeout.tv_sec * 1000 )
+ ( lp->write_timeout.tv_usec / 1000 );
ssize_t writeret = g_sys_write_func( fd,(const char*)buf + wrotelen,nbyte - wrotelen );
if( writeret > 0 )
{
wrotelen += writeret;
}
while( wrotelen < nbyte )
{
struct pollfd pf = { 0 };
pf.fd = fd;
pf.events = ( POLLOUT | POLLERR | POLLHUP );
poll( &pf,1,timeout );
writeret = g_sys_write_func( fd,(const char*)buf + wrotelen,nbyte - wrotelen );
if( writeret <= 0 )
{
break;
}
wrotelen += writeret ;
}
return wrotelen;
}
ssize_t sendto(int socket, const void *message, size_t length,
int flags, const struct sockaddr *dest_addr,
socklen_t dest_len)
{
/*
1.no enable sys call ? sys
2.( !lp || lp is non block ) ? sys
3.try
4.wait
5.try
*/
HOOK_SYS_FUNC( sendto );
if( !co_is_enable_sys_hook() )
{
return g_sys_sendto_func( socket,message,length,flags,dest_addr,dest_len );
}
rpchook_t *lp = get_by_fd( socket );
if( !lp || ( O_NONBLOCK & lp->user_flag ) )
{
return g_sys_sendto_func( socket,message,length,flags,dest_addr,dest_len );
}
ssize_t ret = g_sys_sendto_func( socket,message,length,flags,dest_addr,dest_len );
if( ret < 0 && EAGAIN == errno )
{
int timeout = ( lp->write_timeout.tv_sec * 1000 )
+ ( lp->write_timeout.tv_usec / 1000 );
struct pollfd pf = { 0 };
pf.fd = socket;
pf.events = ( POLLOUT | POLLERR | POLLHUP );
poll( &pf,1,timeout );
ret = g_sys_sendto_func( socket,message,length,flags,dest_addr,dest_len );
}
return ret;
}
ssize_t recvfrom(int socket, void *buffer, size_t length,
int flags, struct sockaddr *address,
socklen_t *address_len)
{
HOOK_SYS_FUNC( recvfrom );
if( !co_is_enable_sys_hook() )
{
return g_sys_recvfrom_func( socket,buffer,length,flags,address,address_len );
}
rpchook_t *lp = get_by_fd( socket );
if( !lp || ( O_NONBLOCK & lp->user_flag ) )
{
return g_sys_recvfrom_func( socket,buffer,length,flags,address,address_len );
}
int timeout = ( lp->read_timeout.tv_sec * 1000 )
+ ( lp->read_timeout.tv_usec / 1000 );
struct pollfd pf = { 0 };
pf.fd = socket;
pf.events = ( POLLIN | POLLERR | POLLHUP );
poll( &pf,1,timeout );
ssize_t ret = g_sys_recvfrom_func( socket,buffer,length,flags,address,address_len );
return ret;
}
ssize_t send(int socket, const void *buffer, size_t length, int flags)
{
HOOK_SYS_FUNC( send );
if( !co_is_enable_sys_hook() )
{
return g_sys_send_func( socket,buffer,length,flags );
}
rpchook_t *lp = get_by_fd( socket );
if( !lp || ( O_NONBLOCK & lp->user_flag ) )
{
return g_sys_send_func( socket,buffer,length,flags );
}
size_t wrotelen = 0;
int timeout = ( lp->write_timeout.tv_sec * 1000 )
+ ( lp->write_timeout.tv_usec / 1000 );
ssize_t writeret = g_sys_send_func( socket,buffer,length,flags );
if( writeret > 0 )
{
wrotelen += writeret;
}
while( wrotelen < length )
{
struct pollfd pf = { 0 };
pf.fd = socket;
pf.events = ( POLLOUT | POLLERR | POLLHUP );
poll( &pf,1,timeout );
writeret = g_sys_send_func( socket,(const char*)buffer + wrotelen,length - wrotelen,flags );
if( writeret <= 0 )
{
break;
}
wrotelen += writeret ;
}
return wrotelen;
}
ssize_t recv( int socket, void *buffer, size_t length, int flags )
{
HOOK_SYS_FUNC( recv );
if( !co_is_enable_sys_hook() )
{
return g_sys_recv_func( socket,buffer,length,flags );
}
rpchook_t *lp = get_by_fd( socket );
if( !lp || ( O_NONBLOCK & lp->user_flag ) )
{
return g_sys_recv_func( socket,buffer,length,flags );
}
int timeout = ( lp->read_timeout.tv_sec * 1000 )
+ ( lp->read_timeout.tv_usec / 1000 );
struct pollfd pf = { 0 };
pf.fd = socket;
pf.events = ( POLLIN | POLLERR | POLLHUP );
int pollret = poll( &pf,1,timeout );
ssize_t readret = g_sys_recv_func( socket,buffer,length,flags );
if( readret < 0 )
{
co_log_err("CO_ERR: read fd %d ret %ld errno %d poll ret %d timeout %d",
socket,readret,errno,pollret,timeout);
}
return readret;
}
int poll(struct pollfd fds[], nfds_t nfds, int timeout)
{
HOOK_SYS_FUNC( poll );
if( !co_is_enable_sys_hook() )
{
return g_sys_poll_func( fds,nfds,timeout );
}
return co_poll( co_get_epoll_ct(),fds,nfds,timeout );
}
int setsockopt(int fd, int level, int option_name,
const void *option_value, socklen_t option_len)
{
HOOK_SYS_FUNC( setsockopt );
if( !co_is_enable_sys_hook() )
{
return g_sys_setsockopt_func( fd,level,option_name,option_value,option_len );
}
rpchook_t *lp = get_by_fd( fd );
if( lp && SOL_SOCKET == level )
{
struct timeval *val = (struct timeval*)option_value;
if( SO_RCVTIMEO == option_name )
{
memcpy( &lp->read_timeout,val,sizeof(*val) );
}
else if( SO_SNDTIMEO == option_name )
{
memcpy( &lp->write_timeout,val,sizeof(*val) );
}
}
return g_sys_setsockopt_func( fd,level,option_name,option_value,option_len );
}
int fcntl(int fildes, int cmd, ...)
{
HOOK_SYS_FUNC( fcntl );
if( fildes < 0 )
{
return __LINE__;
}
va_list arg_list;
va_start( arg_list,cmd );
int ret = -1;
rpchook_t *lp = get_by_fd( fildes );
switch( cmd )
{
case F_DUPFD:
{
int param = va_arg(arg_list,int);
ret = g_sys_fcntl_func( fildes,cmd,param );
break;
}
case F_GETFD:
{
ret = g_sys_fcntl_func( fildes,cmd );
break;
}
case F_SETFD:
{
int param = va_arg(arg_list,int);
ret = g_sys_fcntl_func( fildes,cmd,param );
break;
}
case F_GETFL:
{
ret = g_sys_fcntl_func( fildes,cmd );
break;
}
case F_SETFL:
{
int param = va_arg(arg_list,int);
int flag = param;
if( co_is_enable_sys_hook() && lp )
{
flag |= O_NONBLOCK;
}
ret = g_sys_fcntl_func( fildes,cmd,flag );
if( 0 == ret && lp )
{
lp->user_flag = param;
}
break;
}
case F_GETOWN:
{
ret = g_sys_fcntl_func( fildes,cmd );
break;
}
case F_SETOWN:
{
int param = va_arg(arg_list,int);
ret = g_sys_fcntl_func( fildes,cmd,param );
break;
}
case F_GETLK:
{
struct flock *param = va_arg(arg_list,struct flock *);
ret = g_sys_fcntl_func( fildes,cmd,param );
break;
}
case F_SETLK:
{
struct flock *param = va_arg(arg_list,struct flock *);
ret = g_sys_fcntl_func( fildes,cmd,param );
break;
}
case F_SETLKW:
{
struct flock *param = va_arg(arg_list,struct flock *);
ret = g_sys_fcntl_func( fildes,cmd,param );
break;
}
}
va_end( arg_list );
return ret;
}
/*
void *pthread_getspecific(pthread_key_t key)
{
HOOK_SYS_FUNC( pthread_getspecific );
//printf("hook_getspec (%ld)\n",(long)key);
return g_sys_pthread_getspecific_func( key );
}
int pthread_setspecific(pthread_key_t key, const void *value)
{
HOOK_SYS_FUNC( pthread_setspecific );
//printf("hook_setspec (%ld)\n",(long)key);
return g_sys_pthread_setspecific_func( key,value );
}
struct tm *localtime_r( const time_t *timep, struct tm *result )
{
if( result )
{
memset( result,0,sizeof(*result) );
}
return result;
}
*/
//static int g_rwlock_cnt[ 65536 ] = { 0 };
/*
static pid_t __GetThreadPid()
{
char **p = (char**)pthread_self();
return p ? *(pid_t*)(p + 18) : 0;
}
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
{
HOOK_SYS_FUNC( pthread_rwlock_rdlock )
pid_t pid = __GetThreadPid();
int ret = g_sys_pthread_rwlock_rdlock_func(rwlock);
//++g_rwlock_cnt[ pid ];
return ret;
}
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
{
HOOK_SYS_FUNC( pthread_rwlock_wrlock )
pid_t pid = __GetThreadPid();
int ret = g_sys_pthread_rwlock_wrlock_func(rwlock);
//++g_rwlock_cnt[ pid ];
return ret;
}
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
{
HOOK_SYS_FUNC( pthread_rwlock_unlock )
pid_t pid = __GetThreadPid();
int ret = g_sys_pthread_rwlock_unlock_func(rwlock);
//--g_rwlock_cnt[ pid ];
return ret;
}
*/
/*
int GetThreadRWLockCnt( )
{
return g_rwlock_cnt[ __GetThreadPid() ];
}
*/
//g++ -O2 -fPIC -DLINUX -pipe -c rpchook_sys_call.cpp -o rpcdump.o
//g++ -fPIC -shared -O2 -pipe rpcdump.o -o librpcdump.so
//export LD_PRELOAD=$PWD/librpcdump.so
//./test_kvcli_cpu batch_str str_kvsvr_cli.conf 1000
//export LD_PRELOAD=;
//~/QQMail/comm2/svrkit> vi skutils.cpp
//gzrd_Lib_CPP_Version_ID--start
void co_enable_hook_sys() //这函数必须在这里,否则本文件会被忽略!!!
{
stCoRoutine_t *co = GetCurrThreadCo();
if( co )
{
co->cEnableSysHook = 1;
}
}