Skip to content

Commit fa0a059

Browse files
committed
Modify sendfile test
1 parent c65381c commit fa0a059

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

trantor/net/inner/TcpConnectionImpl.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <sys/stat.h>
1010
#include <fcntl.h>
1111

12-
#define FETCH_SIZE 2048;
1312
using namespace trantor;
1413

1514

trantor/tests/SendfileTest.cc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,31 @@ int main(int argc, char* argv[])
4848
server.setRecvMessageCallback([](const TcpConnectionPtr &connectionPtr,MsgBuffer *buffer){
4949
//LOG_DEBUG<<"recv callback!";
5050
});
51-
server.setConnectionCallback([=](const TcpConnectionPtr& connPtr){
51+
int counter=0;
52+
server.setConnectionCallback([=,&counter](const TcpConnectionPtr& connPtr){
5253
if(connPtr->connected())
5354
{
5455
LOG_DEBUG<<"New connection";
55-
std::thread t([=](){
56+
std::thread t([=,&counter](){
5657
for(int i=0;i<5;i++)
5758
{
5859
connPtr->sendFile(argv[1]);
5960
char str[64];
60-
sprintf(str,"\n%d files sent!\n",i+1);
61+
counter++;
62+
sprintf(str,"\n%d files sent!\n",counter);
6163
connPtr->send(str,strlen(str));
6264
}
6365
});
6466
t.detach();
67+
68+
for(int i=0;i<3;i++){
69+
connPtr->sendFile(argv[1]);
70+
char str[64];
71+
counter++;
72+
sprintf(str,"\n%d files sent!\n",counter);
73+
connPtr->send(str,strlen(str));
74+
}
75+
6576
}
6677
else if(connPtr->disconnected())
6778
{

0 commit comments

Comments
 (0)