Send ldb.logs to the debugging client as a multi-bulk reply * consisting of simple strings. Log entries which include newlines have them * replaced with spaces. The entries sent are also consumed. */
| 1931 | * consisting of simple strings. Log entries which include newlines have them |
| 1932 | * replaced with spaces. The entries sent are also consumed. */ |
| 1933 | void ldbSendLogs(void) { |
| 1934 | sds proto = sdsempty(); |
| 1935 | proto = sdscatfmt(proto,"*%i\r\n", (int)listLength(ldb.logs)); |
| 1936 | while(listLength(ldb.logs)) { |
| 1937 | listNode *ln = listFirst(ldb.logs); |
| 1938 | proto = sdscatlen(proto,"+",1); |
| 1939 | sdsmapchars((sds)ln->value,"\r\n"," ",2); |
| 1940 | proto = sdscatsds(proto,(sds)ln->value); |
| 1941 | proto = sdscatlen(proto,"\r\n",2); |
| 1942 | listDelNode(ldb.logs,ln); |
| 1943 | } |
| 1944 | if (connWrite(ldb.conn,proto,sdslen(proto)) == -1) { |
| 1945 | /* Avoid warning. We don't check the return value of write() |
| 1946 | * since the next read() will catch the I/O error and will |
| 1947 | * close the debugging session. */ |
| 1948 | } |
| 1949 | sdsfree(proto); |
| 1950 | } |
| 1951 | |
| 1952 | /* Start a debugging session before calling EVAL implementation. |
| 1953 | * The technique we use is to capture the client socket file descriptor, |
no test coverage detected