Subject: |
Re: [Merge] ~dirk.zimoch/epics-base:iocLogClientFixesTry2 into epics-base:7.0 |
From: |
Dirk Zimoch via Core-talk <[email protected]> |
To: |
[email protected] |
Date: |
Thu, 19 Sep 2019 06:39:00 -0000 |
epicsErrlogTest.c: I have not yet looked into this but I guess it should be possible.
VxWorks 6: I don't have vxWorks 6 running on my IOCs. Was always low on my work list.
Diff comments:
> diff --git a/modules/libcom/src/log/iocLog.c b/modules/libcom/src/log/iocLog.c
> index e62da20..8cb1349 100644
> --- a/modules/libcom/src/log/iocLog.c
> +++ b/modules/libcom/src/log/iocLog.c
> @@ -75,6 +77,14 @@ void epicsShareAPI epicsShareAPI iocLogFlush (void)
> }
>
> /*
> + * logClientDestroy()
> + */
> +static void iocLogClientDestroy (logClientId id)
Oops.
> +{
> + errlogRemoveListeners (logClientSendMessage, id);
> +}
> +
> +/*
> * iocLogClientInit()
> */
> static logClientId iocLogClientInit (void)
> diff --git a/modules/libcom/src/log/logClient.c b/modules/libcom/src/log/logClient.c
> index 99ee671..6671d27 100644
> --- a/modules/libcom/src/log/logClient.c
> +++ b/modules/libcom/src/log/logClient.c
> @@ -21,11 +21,9 @@
> #include <string.h>
> #include <stdio.h>
>
> -#define epicsExportSharedSymbols
I include epicsExport.h now and that defines epicsExportSharedSymbols. My Windows build looks ok.
I am never sure about this epicsExport stuff but I thought epicsExport.h is supposed to be included (and thus epicsExportSharedSymbols to be defined) after all other EPICS headers and before the headers of this module?
> #include "dbDefs.h"
> #include "epicsEvent.h"
> #include "iocLog.h"
> -#include "errlog.h"
> #include "epicsMutex.h"
> #include "epicsThread.h"
> #include "epicsTime.h"
> @@ -176,60 +175,59 @@ static void sendMessageChunk(logClient * pClient, const char * message) {
> unsigned msgBufBytesLeft =
> sizeof ( pClient->msgBuf ) - pClient->nextMsgIndex;
>
> - if ( strSize > msgBufBytesLeft ) {
> - int status;
> -
> - if ( ! pClient->connected ) {
> - break;
> - }
> -
> - if ( msgBufBytesLeft > 0u ) {
> - memcpy ( & pClient->msgBuf[pClient->nextMsgIndex],
> - message, msgBufBytesLeft );
> - pClient->nextMsgIndex += msgBufBytesLeft;
> - strSize -= msgBufBytesLeft;
> - message += msgBufBytesLeft;
> - }
> -
> - status = send ( pClient->sock, pClient->msgBuf,
> - pClient->nextMsgIndex, 0 );
> - if ( status > 0 ) {
> - unsigned nSent = (unsigned) status;
> - if ( nSent < pClient->nextMsgIndex ) {
> - unsigned newNextMsgIndex = pClient->nextMsgIndex - nSent;
> - memmove ( pClient->msgBuf, & pClient->msgBuf[nSent],
> - newNextMsgIndex );
> - pClient->nextMsgIndex = newNextMsgIndex;
> - }
> - else {
> - pClient->nextMsgIndex = 0u;
> - }
> - }
> - else {
> - if ( ! pClient->shutdown ) {
> - char sockErrBuf[64];
> - if ( status ) {
> - epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
> - }
> - else {
> - strcpy ( sockErrBuf, "server initiated disconnect" );
> - }
> - fprintf ( stderr, "log client: lost contact with log server at \"%s\" because \"%s\"\n",
> - pClient->name, sockErrBuf );
> - }
> - logClientClose ( pClient );
> - break;
> - }
> + if ( msgBufBytesLeft < strSize && pClient->nextMsgIndex != 0u && pClient->connected)
> + {
> + /* buffer is full, thus flush it */
> + logClientFlush ( pClient );
> + msgBufBytesLeft = sizeof ( pClient->msgBuf ) - pClient->nextMsgIndex;
> }
> - else {
> - memcpy ( & pClient->msgBuf[pClient->nextMsgIndex],
> - message, strSize );
> - pClient->nextMsgIndex += strSize;
> + if ( msgBufBytesLeft == 0u ) {
> + fprintf ( stderr, "log client: messages to \"%s\" are lost\n",
> + pClient->name );
> break;
> }
> + if ( msgBufBytesLeft > strSize) msgBufBytesLeft = strSize;
> + memcpy ( & pClient->msgBuf[pClient->nextMsgIndex],
> + message, msgBufBytesLeft );
> + pClient->nextMsgIndex += msgBufBytesLeft;
> + strSize -= msgBufBytesLeft;
> + message += msgBufBytesLeft;
> }
> }
>
> +/*
> + * epicsSockCountUnsentBytes ()
> + * Should go to osd socket support
I think epicsSocketUnsentData() suggests to return the data itself instead of the byte count.
Should it return -1 when it is not possible to find out the amount of unsent data?
> + */
> +#if defined (_WIN32) && WINVER >= _WIN32_WINNT_WIN10
> +#include <mstcpip.h>
> +#endif
> +
> +static int epicsSockCountUnsentBytes(SOCKET sock) {
> +#if defined (_WIN32) && WINVER >= _WIN32_WINNT_WIN10
> +/* Windows 10 Version 1703 / Server 2016 */
> +/* https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-tcp_info_v0 */
> + DWORD infoVersion = 0, bytesReturned;
> + TCP_INFO_v0 tcpInfo;
> + int status;
> + if ((status = WSAIoctl(sock, SIO_TCP_INFO, &infoVersion, sizeof(infoVersion),
> + &tcpInfo, sizeof(tcpInfo), &bytesReturned, NULL, NULL)) == 0)
> + return tcpInfo.BytesInFlight;
> +#elif defined (SO_NWRITE)
> +/* macOS / iOS */
> +/* https://www.unix.com/man-page/osx/2/setsockopt/ */
> + int unsent;
> + if (getsockopt(sock, SOL_SOCKET, SO_NWRITE, &unsent) == 0)
> + return unsent;
> +#elif defined (TIOCOUTQ)
> +/* Linux */
> +/* https://linux.die.net/man/7/tcp */
> + int unsent;
> + if (ioctl(sock, TIOCOUTQ, &unsent) == 0)
> + return unsent;
> +#endif
> + return 0;
> +}
>
> /*
> * logClientSend ()
--
https://code.launchpad.net/~dirk.zimoch/epics-base/+git/epics-base/+merge/372925
Your team EPICS Core Developers is subscribed to branch epics-base:7.0.
- References:
- [Merge] ~dirk.zimoch/epics-base:iocLogClientFixesTry2 into epics-base:7.0 Dirk Zimoch via Core-talk
- Navigate by Date:
- Prev:
Re: a race condition between rsrv_init() and casStatsFetch() Kim, Kukhee via Core-talk
- Next:
Re: [Merge] ~dirk.zimoch/epics-base:iocLogClientFixesTry2 into epics-base:7.0 Dirk Zimoch via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
<2019>
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: [Merge] ~dirk.zimoch/epics-base:iocLogClientFixesTry2 into epics-base:7.0 Andrew Johnson via Core-talk
- Next:
Re: [Merge] ~dirk.zimoch/epics-base:iocLogClientFixesTry2 into epics-base:7.0 Dirk Zimoch via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
<2019>
2020
2021
2022
2023
2024
|