Changeset 8784 in ntrip for trunk


Ignore:
Timestamp:
Aug 1, 2019, 9:23:25 AM (5 years ago)
Author:
stoecker
Message:

fix chunked transfer in case of buffer full situations

Location:
trunk/ntripserver
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ntripserver/README

    r2277 r8784  
    33----------------------------------------------------------------------
    44
    5 (c) German Federal Agency for Cartography and Geodesy (BKG), 2002-2007
     5(c) German Federal Agency for Cartography and Geodesy (BKG), 2002-2019
    66
    77
     
    213213Further information
    214214-------------------
    215 URL:    http://igs.bkg.bund.de/index_ntrip.htm
     215URL:    https://igs.bkg.bund.de/ntrip/index
    216216E-mail: euref-ip@bkg.bund.de
  • trunk/ntripserver/ntripserver.c

    • Property svn:keywords set to Id Revision Date
    r2276 r8784  
    11/*
    2  * $Id: ntripserver.c,v 1.50 2010/01/21 09:00:49 stoecker Exp $
     2 * $Id$
    33 *
    4  * Copyright (c) 2003...2007
     4 * Copyright (c) 2003...2019
    55 * German Federal Agency for Cartography and Geodesy (BKG)
     6 * Dirk Stöcker (Alberding GmbH)
    67 *
    78 * Developed for Networked Transport of RTCM via Internet Protocol (NTRIP)
     
    1617 *
    1718 * For latest information and updates, access:
    18  * http://igs.bkg.bund.de/index_ntrip_down.htm
     19 * https://igs.bkg.bund.de/ntrip/index
    1920 *
    20  * BKG, Frankfurt, Germany, February 2007
     21 * BKG, Frankfurt, Germany, August 2019
    2122 * E-mail: euref-ip@bkg.bund.de
    2223 *
     
    3132 * GNU General Public License for more details.
    3233 *
    33  * You should have received a copy of the GNU General Public License
    34  * along with this program; if not, write to the Free Software
    35  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     34 * You should have received a copy of the GNU General Public License along
     35 * with this program; if not, write to the Free Software Foundation, Inc.,
     36 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    3637 */
    3738
    38 /* CVS revision and version */
    39 static char revisionstr[] = "$Revision: 1.50 $";
    40 static char datestr[]     = "$Date: 2010/01/21 09:00:49 $";
     39/* SVN revision and version */
     40static char revisionstr[] = "$Revision$";
     41static char datestr[]     = "$Date$";
    4142
    4243#include <ctype.h>
     
    241242
    242243  {
    243   char *a;
    244   int i = 0;
    245   for(a = revisionstr+11; *a && *a != ' '; ++a)
    246     revisionstr[i++] = *a;
    247   revisionstr[i] = 0;
    248   datestr[0] = datestr[7];
    249   datestr[1] = datestr[8];
    250   datestr[2] = datestr[9];
    251   datestr[3] = datestr[10];
    252   datestr[5] = datestr[12];
    253   datestr[6] = datestr[13];
    254   datestr[8] = datestr[15];
    255   datestr[9] = datestr[16];
    256   datestr[4] = datestr[7] = '-';
    257   datestr[10] = 0;
     244    char *a;
     245    int i = 2;
     246    strcpy(revisionstr, "1.");
     247    for(a = revisionstr+11; *a && *a != ' '; ++a)
     248      revisionstr[i++] = *a;
     249    revisionstr[i] = 0;
     250    i = 0;
     251    for(a = datestr+7; *a && *a != ' '; ++a)
     252      datestr[i++] = *a;
     253    datestr[i] = 0;
    258254  }
    259255
     
    13721368  char     szSendBuffer[BUFSZ] = "";
    13731369  int      nBufferBytes = 0;
     1370  int      remainChunk = 0;
    13741371
    13751372   /* RTSP / RTP Mode */
     
    15901587    else if((nBufferBytes)  && (outmode == HTTP))
    15911588    {
    1592       int i, nChunkBytes, j = 1;
    1593       nChunkBytes = snprintf(szSendBuffer, sizeof(szSendBuffer),"%x\r\n",
    1594       nBufferBytes);
    1595       send(sock, szSendBuffer, nChunkBytes, MSG_DONTWAIT);
    1596       if((i = send(sock, buffer, (size_t)nBufferBytes, MSG_DONTWAIT))
    1597       != nBufferBytes)
    1598       {
     1589      if(remainChunk)
     1590      {
     1591        int i = send(sock, buffer, (size_t)remainChunk, MSG_DONTWAIT);
    15991592        if(i < 0)
    16001593        {
     
    16071600        else if(i)
    16081601        {
    1609           while(j>0)
    1610           {
    1611             j = send(sock, buffer, (size_t)BUFSZ, MSG_DONTWAIT);
    1612           }
     1602          memmove(buffer, buffer+i, (size_t)(nBufferBytes-i));
     1603          nBufferBytes -= i;
     1604          remainChunk -= i;
    16131605        }
    16141606      }
    16151607      else
     1608      {
     1609        int i, nChunkBytes;
     1610        nChunkBytes = snprintf(szSendBuffer, sizeof(szSendBuffer),"%x\r\n",
     1611        nBufferBytes);
     1612        send(sock, szSendBuffer, nChunkBytes, 0);
     1613        if((i = send(sock, buffer, (size_t)nBufferBytes, MSG_DONTWAIT))
     1614        != nBufferBytes)
     1615        {
     1616          if(i < 0)
     1617          {
     1618            if(errno != EAGAIN)
     1619            {
     1620              perror("WARNING: could not send data to Destination caster");
     1621              return;
     1622            }
     1623          }
     1624          else if(i)
     1625          {
     1626            memmove(buffer, buffer+i, (size_t)(nBufferBytes-i));
     1627            nBufferBytes -= i;
     1628            remainChunk = nBufferBytes;
     1629          }
     1630        }
     1631      }
     1632      if(!remainChunk)
    16161633      {
    16171634        send(sock, "\r\n", strlen("\r\n"), MSG_DONTWAIT);
Note: See TracChangeset for help on using the changeset viewer.