Skip to content

Commit 27937ae

Browse files
v3.24
IMPROVEMENTS: * Allowed adding spaces after section name in .ini file BUG FIXES: * Was rename parameter `benchmark` to `statistics`
1 parent df1578b commit 27937ae

File tree

8 files changed

+41
-76
lines changed

8 files changed

+41
-76
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ FEATURES:
55
IMPROVEMENTS:
66
BUG FIXES:
77

8+
## v3.24
9+
10+
IMPROVEMENTS:
11+
12+
* Allowed adding spaces after section name in .ini file
13+
14+
BUG FIXES:
15+
16+
* Was rename parameter `benchmark` to `statistics`
17+
818
## v3.23
919

1020
IMPROVEMENTS:

comet.ini

+10-19
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
; docs for CppComet https://comet-server.com/wiki/doku.php
55
;
66

7-
[main]
8-
7+
[main]
8+
99
; Password for accessing comet server api
1010
password = 0000000000000000000000000000000000000000000000000000000000000000
11-
11+
1212
[db]
1313
host = localhost
1414
user = root
@@ -17,7 +17,7 @@ name = comet_db
1717
port = 3306
1818

1919
[ws]
20-
ip = 0.0.0.0
20+
ip = 0.0.0.0
2121
thread_num = 4 ; number of threads for receive message from websockets
2222
statistics = 10 ;Interval between load measurements (0 = not measured)
2323
port = 8087 ; When connecting to js api, do not forget to specify the port in the node parameter
@@ -26,27 +26,18 @@ maxUptime = 0 ; The maximum value of uptime after which the connection is discon
2626
host = * ; comma separated hosts from which allows receiving connections, or asterisk symbol for allowing connections from any host
2727

2828
[cometql]
29-
ip = 0.0.0.0
29+
ip = 0.0.0.0
3030
thread_num = 3 ; number of threads for receive message from cometql
3131
statistics = 10
3232
port = 3300
33-
uptimeTestInterval = 600
34-
maxUptime = 0
35-
33+
uptimeTestInterval = 600
34+
maxUptime = 0
35+
3636
[statistics]
3737
allow = true ; https://comet-server.com/wiki/doku.php/en:comet:ini-file#section_statistics
3838

3939

40-
[cluster]
41-
42-
; Параметры кластера
43-
cometql = []host1.ru:3300@password
44-
cometql = []host2.ru:3300@password
45-
cometql = []host3.ru:3300@password
46-
cometql = []host4.ru:3300@password
47-
cometql = []host5.ru:3300@password
48-
49-
[content-type]
40+
[content-type]
5041
js = application/javascript
5142

5243
[log]
@@ -68,5 +59,5 @@ ServerServer = 500
6859
SimpleRedisClient = 500
6960
tcpServer = 500
7061
CometQLCluster = 500
71-
devManager = 500
62+
devManager = 500
7263
dbLink = 500

src/Client_connection.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -1220,9 +1220,9 @@ char* Client_connection::checking_event_name(thread_data* local_buf, const char*
12201220
*/
12211221
int Client_connection::web_pipe_msg_v1(thread_data* local_buf, char* event_data,int client, int len)
12221222
{
1223-
if(!appConf::instance()->get_bool('ws', 'support_old_api'))
1223+
if(!appConf::instance()->get_bool("ws", "support_old_api"))
12241224
{
1225-
return;
1225+
return 0;
12261226
}
12271227

12281228
bool send_user_id = true;
@@ -1576,7 +1576,8 @@ int Client_connection::get_favicon_request(int client, int len, thread_data* loc
15761576
}
15771577

15781578
int Client_connection::get_custom_request(int client, int len, thread_data* local_buf)
1579-
{
1579+
{
1580+
TagLoger::log(Log_ClientServer, 0, ">Client GET get_custom_request\n");
15801581
char *p = local_buf->buf.getData();
15811582
int urlStart = strlen("GET ");
15821583
p = p + urlStart;
@@ -1590,6 +1591,11 @@ int Client_connection::get_custom_request(int client, int len, thread_data* loca
15901591

15911592
p[urlEnd - 1] = 0;
15921593
char *uri = p;
1594+
if(strncmp(uri, "/comet-server", strlen("/comet-server")) == 0)
1595+
{
1596+
uri += strlen("/comet-server");
1597+
}
1598+
15931599
std::string name(appConf::instance()->get_string("main", "base_dir"));
15941600
if(name.empty())
15951601
{

src/devManager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ class devManager
449449
index = new devInfo(appConf::instance()->get_chars("main", "password") );
450450
intervalLoop::instance()->add([](int uptime, thread_data* local_buf)
451451
{
452-
int benchmark = appConf::instance()->get_int("ws", "benchmark");
452+
int benchmark = appConf::instance()->get_int("ws", "statistics");
453453
if( !benchmark || uptime% benchmark != 0)
454454
{
455455
return;

src/ini_parser/ini_parser.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ class confVar{
149149
}
150150
else if(val.compare(0, 2, "[]"))
151151
{
152-
list.push_back(val.erase(0, 2));
152+
std::string arrStr = val;
153+
list.push_back(arrStr.erase(0, 2));
153154
}
154155
}
155156

@@ -406,7 +407,7 @@ class ini_parser
406407
std::string key = extract_key(line);
407408
std::string value = extract_value(line);
408409

409-
//printf("assignment:%s[%s]=%s\n", current_section.data(), key.data(), value.data());
410+
printf("assignment:%s[%s]=%s\n", current_section.data(), key.data(), value.data());
410411
set_value(current_section, key, value);
411412
}
412413

@@ -459,8 +460,8 @@ class ini_parser
459460
* bracket and the last character is a closing bracket.
460461
*/
461462
bool is_section_start_line(const std::string& line) const
462-
{
463-
return (line.length() > 0) && (line[0] == '[') && (line[line.length() - 1] == ']');
463+
{
464+
return (line.length() > 0) && (line[0] == '[') && (line[line.find_last_not_of(" \r\t")] == ']');
464465
}
465466

466467
/*

src/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ void th_startServer(int threadid, const char* server_name)
8686

8787

8888

89-
if(appConf::instance()->get_int(server_name, "benchmark") > 0)
89+
if(appConf::instance()->get_int(server_name, "statistics") > 0)
9090
{
9191
tcpServer <connectionType>::instance()->benchmark = 1;
92-
tcpServer <connectionType>::instance()->bm.stat_interval = appConf::instance()->get_int(server_name, "benchmark");
92+
tcpServer <connectionType>::instance()->bm.stat_interval = appConf::instance()->get_int(server_name, "statistics");
9393
}
9494
else
9595
{

src/main.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@
102102
</body>\
103103
</html>"
104104

105-
#define MYSQL_SERVERNAME "CppComet 3.23"
106-
#define MYSQL_SYSTEMVARIBLE "CppComet 3.23 (comet-server.com, [email protected])"
105+
#define MYSQL_SERVERNAME "CppComet 3.24"
106+
#define MYSQL_SYSTEMVARIBLE "CppComet 3.24 (comet-server.com, [email protected])"
107107

108108
#define maxValue( a, b ) ( (a) > (b) ? (a) : (b) )
109109
#define minValue( a, b ) ( (a) < (b) ? (a) : (b) )

src/tcpServer_benchmark.h

+2-45
Original file line numberDiff line numberDiff line change
@@ -111,49 +111,7 @@ class tcpServer_benchmark: public intervalLoopObject
111111
}
112112
printf("---------------------------------------------\n");
113113
}
114-
115-
void filePrint()
116-
{
117-
if(fp == NULL)
118-
{
119-
int len = strlen(name);
120-
memcpy(file_name, name, len);
121-
memcpy(file_name+len, ".csv", 4);
122-
123-
fp = fopen(file_name, "w");
124-
fprintf(fp, "work_time,conections,addClient,deleteClient,handle_message,ps_addClient,ps_deleteClient,ps_handle_message,loadavg_1,loadavg_2,loadavg_3,running_processes,total_processes" );
125-
for(int i = 0; i< th_num; i++)
126-
{
127-
fprintf(fp, ",th_status_count%d,th_ps_status_count%d", i, i);
128-
}
129-
fprintf(fp, "\n");
130-
}
131-
132-
FILE* loadavgFp = fopen("/proc/loadavg", "r");
133-
float loadavg_1, loadavg_2, loadavg_3;
134-
int running_processes, total_processes;
135-
136-
fscanf(loadavgFp, "%5f %5f %5f %5d/%5d", &loadavg_1, &loadavg_2, &loadavg_3, &running_processes, &total_processes);
137-
fclose(loadavgFp);
138-
139-
fprintf(fp, "%d,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%d,%d",
140-
cprint_count, conections, addClient, deleteClient, handle_message, ps_addClient, ps_deleteClient, ps_handle_message, loadavg_1, loadavg_2, loadavg_3, running_processes, total_processes);
141-
142-
for(int i = 0; i< th_num; i++)
143-
{
144-
fprintf(fp, ",%d,%.2f",th_status_count[i], th_ps_status_count[i]);
145-
}
146-
fprintf(fp, "\n");
147-
fileCountLines++;
148-
149-
if(fileCountLines > appConf::instance()->get_int("benchmark", "file_save"))
150-
{
151-
fileCountLines = 0;
152-
fclose(fp);
153-
fp = fopen(file_name, "a");
154-
}
155-
}
156-
114+
157115
int getAddClient(){ return addClient; }
158116
float getPsAddClient(){ return ps_addClient; }
159117

@@ -335,8 +293,7 @@ class tcpServer_benchmark: public intervalLoopObject
335293

336294
cprint_count+=stat_interval;
337295

338-
if(appConf::instance()->get_bool("benchmark", "to_log")) cprint();
339-
if(appConf::instance()->get_bool("benchmark", "to_file")) filePrint();
296+
if(appConf::instance()->get_bool("statistics", "to_log")) cprint();
340297
}
341298
};
342299

0 commit comments

Comments
 (0)