133 |
return ret; |
return ret; |
134 |
} |
} |
135 |
|
|
136 |
|
// Check if last transaction has timed out, in which case |
137 |
|
// we'll retry wait and flush for some pending garbage... |
138 |
|
if (pClient->iTimeoutCount > 0) { |
139 |
|
cchResult = sizeof(achResult); |
140 |
|
ret = lscp_client_recv(pClient, achResult, &cchResult, pClient->iTimeout); |
141 |
|
if (ret == LSCP_OK) { |
142 |
|
// We've got rid of timeout trouble (hopefully). |
143 |
|
pClient->iTimeoutCount = 0; |
144 |
|
} else { |
145 |
|
// Things are worse than before. Fake a result message. |
146 |
|
iErrno = (int) ret; |
147 |
|
pszResult = "Failure during flush timeout operation"; |
148 |
|
lscp_client_set_result(pClient, pszResult, iErrno); |
149 |
|
return ret; |
150 |
|
} |
151 |
|
} |
152 |
|
|
153 |
// Send data, and then, wait for the result... |
// Send data, and then, wait for the result... |
154 |
cchQuery = strlen(pszQuery); |
cchQuery = strlen(pszQuery); |
155 |
if (send(pClient->cmd.sock, pszQuery, cchQuery, 0) < cchQuery) { |
if (send(pClient->cmd.sock, pszQuery, cchQuery, 0) < cchQuery) { |
205 |
break; |
break; |
206 |
|
|
207 |
case LSCP_TIMEOUT: |
case LSCP_TIMEOUT: |
208 |
|
// We have trouble... |
209 |
|
pClient->iTimeoutCount++; |
210 |
// Fake a result message. |
// Fake a result message. |
211 |
pszResult = "Timeout during receive operation"; |
pszResult = "Timeout during receive operation"; |
212 |
iErrno = (int) ret; |
iErrno = (int) ret; |
350 |
// Make it official. |
// Make it official. |
351 |
ppszSplit[i] = lscp_unquote(&pszHead, 0); |
ppszSplit[i] = lscp_unquote(&pszHead, 0); |
352 |
// Do we need to grow? |
// Do we need to grow? |
353 |
if (++i >= iSize - 1) { |
if (++i >= iSize) { |
354 |
// Yes, but only grow in chunks. |
// Yes, but only grow in chunks. |
355 |
iSize += LSCP_SPLIT_CHUNK1; |
iSize += LSCP_SPLIT_CHUNK1; |
356 |
// Allocate and copy to new split array. |
// Allocate and copy to new split array. |
438 |
// Make it official. |
// Make it official. |
439 |
piSplit[i] = atoi(pchHead); |
piSplit[i] = atoi(pchHead); |
440 |
// Do we need to grow? |
// Do we need to grow? |
441 |
if (++i >= iSize - 1) { |
if (++i >= iSize) { |
442 |
// Yes, but only grow in chunks. |
// Yes, but only grow in chunks. |
443 |
iSize += LSCP_SPLIT_CHUNK1; |
iSize += LSCP_SPLIT_CHUNK1; |
444 |
// Allocate and copy to new split array. |
// Allocate and copy to new split array. |
519 |
pszHead = pch + cchSeps2; |
pszHead = pch + cchSeps2; |
520 |
*pch = (char) 0; |
*pch = (char) 0; |
521 |
} |
} |
522 |
if (++i >= iSize - 1) { |
if (++i >= iSize) { |
523 |
iSize += LSCP_SPLIT_CHUNK1; |
iSize += LSCP_SPLIT_CHUNK1; |
524 |
ppNewSplit = (lscp_param_t *) malloc(iSize * sizeof(lscp_param_t)); |
ppNewSplit = (lscp_param_t *) malloc(iSize * sizeof(lscp_param_t)); |
525 |
if (ppNewSplit) { |
if (ppNewSplit) { |
637 |
iSize = LSCP_SPLIT_SIZE(i); |
iSize = LSCP_SPLIT_SIZE(i); |
638 |
pParams[i].key = strdup(pszKey); |
pParams[i].key = strdup(pszKey); |
639 |
pParams[i].value = strdup(pszValue); |
pParams[i].value = strdup(pszValue); |
640 |
if (++i >= iSize - 1) { |
if (++i >= iSize) { |
641 |
iNewSize = iSize + LSCP_SPLIT_CHUNK1; |
iNewSize = iSize + LSCP_SPLIT_CHUNK1; |
642 |
pNewParams = (lscp_param_t *) malloc(iNewSize * sizeof(lscp_param_t)); |
pNewParams = (lscp_param_t *) malloc(iNewSize * sizeof(lscp_param_t)); |
643 |
for (i = 0; i < iSize; i++) { |
for (i = 0; i < iSize; i++) { |
679 |
|
|
680 |
|
|
681 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
682 |
|
// Server info struct helper functions. |
683 |
|
|
684 |
|
void lscp_server_info_init ( lscp_server_info_t *pServerInfo ) |
685 |
|
{ |
686 |
|
pServerInfo->description = NULL; |
687 |
|
pServerInfo->version = NULL; |
688 |
|
} |
689 |
|
|
690 |
|
void lscp_server_info_free ( lscp_server_info_t *pServerInfo ) |
691 |
|
{ |
692 |
|
if (pServerInfo->description) |
693 |
|
free(pServerInfo->description); |
694 |
|
if (pServerInfo->version) |
695 |
|
free(pServerInfo->version); |
696 |
|
} |
697 |
|
|
698 |
|
void lscp_server_info_reset ( lscp_server_info_t *pServerInfo ) |
699 |
|
{ |
700 |
|
lscp_server_info_free(pServerInfo); |
701 |
|
lscp_server_info_init(pServerInfo); |
702 |
|
} |
703 |
|
|
704 |
|
|
705 |
|
//------------------------------------------------------------------------- |
706 |
// Engine info struct helper functions. |
// Engine info struct helper functions. |
707 |
|
|
708 |
void lscp_engine_info_init ( lscp_engine_info_t *pEngineInfo ) |
void lscp_engine_info_init ( lscp_engine_info_t *pEngineInfo ) |