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. */
| 1908 | * consisting of simple strings. Log entries which include newlines have them |
| 1909 | * replaced with spaces. The entries sent are also consumed. */ |
| 1910 | void ldbSendLogs(void) { |
| 1911 | sds proto = sdsempty(); |
| 1912 | proto = sdscatfmt(proto,"*%i\r\n", (int)listLength(ldb.logs)); |
| 1913 | while(listLength(ldb.logs)) { |
| 1914 | listNode *ln = listFirst(ldb.logs); |
| 1915 | proto = sdscatlen(proto,"+",1); |
| 1916 | sdsmapchars(ln->value,"\r\n"," ",2); |
| 1917 | proto = sdscatsds(proto,ln->value); |
| 1918 | proto = sdscatlen(proto,"\r\n",2); |
| 1919 | listDelNode(ldb.logs,ln); |
| 1920 | } |
| 1921 | if (connWrite(ldb.conn,proto,sdslen(proto)) == -1) { |
| 1922 | /* Avoid warning. We don't check the return value of write() |
| 1923 | * since the next read() will catch the I/O error and will |
| 1924 | * close the debugging session. */ |
| 1925 | } |
| 1926 | sdsfree(proto); |
| 1927 | } |
| 1928 | |
| 1929 | /* Start a debugging session before calling EVAL implementation. |
| 1930 | * The technique we use is to capture the client socket file descriptor, |
no test coverage detected