Socket send () succeeded but failed to send data.

problem description

there is an agent program for SMB, which works normally in most cases, but sometimes the transmission speed drops to 0 (lasts for about a minute and returns to normal)
troubleshooting is that the send () function of socket in the agent program executes successfully, but the packet grab finds that no packet is sent.
Note: this phenomenon does not often occur. I have sent about 1000 files to appear once or twice.

the environmental background of the problems and what methods you have tried

language: C
Environment: Debian 8.8
use package capture software to grab protocol packages for clients, agents, and servers.
1.1.The client did not receive the Response after sending the Request, but judging from the packet grabbed by the SMB server, the server sent the Response.
1.2.Then I added printing in the socket send data section of the agent. Send (), which shows that it has been run successfully. However, the Response information was not found in the grab package of the agent.
that is, the agent also forwards the Response after receiving the Request.
conclusion: the reason why the speed is 0 should be that the smb client fails to receive Response and times out and reconnects with SMB. And restored the connection.

2. When the speed changes to zero, netstat-tnap is executed and no unsent data is found in the sending queue.

what result do you expect? What is the error message actually seen?

I"d like to ask you where to start this question.

Jun.01,2022

the complete code is not convenient to post, and a simplified part of the code is posted. Save the configuration of logging and smb protocol processing. The
program is using the TCP transport.

1.
I found that it's perfectly normal to comment out the smb content handler, just transparently.
but the function deal_with_smb () only handles sending and receiving strings.
2.
repeat the problem again and grab the package. Grab all the tcp bags this time. See if there is a protocol that handles errors, so that the client cannot explain and throw it away. As a result, there is no abnormal tcp package issued by the agent.

do you have any ideas?
who can provide an error-checking idea? thank you

void *do_smb_proxy (void *param)
{
    /* SIGPIPE*/  
    sigset_t mask;
    sigemptyset(&mask);
    sigaddset(&mask, SIGPIPE);
    pthread_sigmask(SIG_BLOCK, &mask, NULL);
    
    struct parse_result *result;
    result = (struct parse_result)malloc(sizeof(struct parse_result));

    int usersockfd = (struct session)param->usersockfd;
    int isosockfd = (struct session)param->isosockfd;

    userbuf = (char *)malloc(maxsize);
    // 
    serverbuf = (char *)malloc(maxsize);
    // 

    while (1)
    {
        // 
        FD_ZERO (&rdfdset);
        FD_SET (usersockfd, &rdfdset);
        FD_SET (isosockfd, &rdfdset);
        dbg("*****wait the message*********\n");    
        if (select (FD_SETSIZE, &rdfdset, NULL, NULL, NULL) < 0)
        {
            goto Error;
        }
    
        if (FD_ISSET (usersockfd, &rdfdset))
        {
            memset(userbuf, 0, maxsize);
            if ((useriolen = read (usersockfd, userbuf, maxsize)) <= 0)
            {
                goto Error;
            }
-sharpif 1
            // result smb
            ret = deal_with_smb(userbuf, useriolen, result);  
            if ( 0 > ret )
            {
                goto Error;
            }            
            _smb_response(usersockfd, result);
-sharpelse
            // server
            ret = _server_write(_server_sock, userbuf, useriolen);
            if ( 0 >= ret )
            {
                goto Error;
            }
-sharpendif
        }
        // 
        // 
        if(FD_ISSET (isosockfd, &rdfdset)) 
        {
            memset(serverbuf, 0, maxsize);
            isoiolen = _server_read(_server_sock, serverbuf, maxsize);
            if ( 0 >= isoiolen )
            {
                goto Error;
            }
-sharpif 1
            // result smb
            ret = ret = deal_with_smb(_server_sock, isoiolen, result);
            if ( 0 > ret )
            {
                goto Error;
            }
            _smb_response2(_server_sock, result); // 
-sharpelse
            ret = write(usersockfd, serverbuf, isoiolen);
            if ( 0 >= ret )
            {
                goto Error;
            }
-sharpendif
        }
    }
Error:
    ......// 
    return NULL;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e536f0-43f68.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e536f0-43f68.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?