Skip to content

Commit

Permalink
more options
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu- committed Aug 9, 2017
1 parent f41494b commit d012aad
Show file tree
Hide file tree
Showing 4 changed files with 444 additions and 489 deletions.
4 changes: 2 additions & 2 deletions common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ unsigned short csum(const unsigned short *ptr,int nbytes) {

return(answer);
}
int set_buf_size(int fd)
int set_buf_size(int fd,int size)
{
int socket_buf_size=1024*1024;
//int socket_buf_size=1024*1024;
if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &socket_buf_size, sizeof(socket_buf_size))<0)
//if(setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
{
Expand Down
17 changes: 14 additions & 3 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

#include<unordered_map>
#include<unordered_set>
#include<list>
using namespace std;


Expand All @@ -61,10 +62,19 @@ typedef int i32_t;

const int max_data_len=1600;
const int buf_len=max_data_len+200;

const u32_t conv_clear_interval=200;
const u32_t timer_interval=400;
const int conv_clear_ratio=40;
const int conv_clear_min=5;
const u32_t conv_timeout=20000;
const int max_conv_num=10000;

/*
const u32_t max_handshake_conn_num=10000;
const u32_t max_ready_conn_num=1000;
//const u32_t anti_replay_window_size=1000;
const int max_conv_num=10000;
const u32_t client_handshake_timeout=5000;
const u32_t client_retry_interval=1000;
Expand All @@ -76,7 +86,7 @@ const int conn_clear_ratio=10;
const int conv_clear_min=5;
const int conn_clear_min=1;
const u32_t conv_clear_interval=1000;
const u32_t conn_clear_interval=1000;
Expand All @@ -94,6 +104,7 @@ const u32_t client_conn_uplink_timeout=client_conn_timeout+2000;
//const uint32_t server_conn_timeout=conv_timeout+60000;//this should be 60s+ longer than conv_timeout,so that conv_manager can destruct convs gradually,to avoid latency glicth
const u32_t server_conn_timeout=conv_timeout+60000;//for test
*/

extern int about_to_exit;

Expand Down Expand Up @@ -132,7 +143,7 @@ u64_t hton64(u64_t a);
bool larger_than_u16(uint16_t a,uint16_t b);
bool larger_than_u32(u32_t a,u32_t b);
void setnonblocking(int sock);
int set_buf_size(int fd);
int set_buf_size(int fd,int size=socket_buf_size);

unsigned short csum(const unsigned short *ptr,int nbytes);

Expand Down
Loading

0 comments on commit d012aad

Please sign in to comment.