You are not logged in.
Pages: 1
Is there a bug in SO_RCVTIMEO?
tcp := TCrtSocket.Open(RawByteString(aServer), RawByteString(IntToStr(FPort)));
if tcp <> nil then begin
try
tcp.ReceiveTimeout := 5 * 1000;
tcp.CreateSockIn;
tcp.CreateSockOut;
Writeln(tcp.SockOut^, aCommand);
aRawData := tcp.SockReceiveString; // Never come back sometimes
Result := string(aRawData).Trim;
except
on E: Exception do
LogException(E, Format('Command: %s - TWhoisQuery.SendCommand()', [aCommand]));
end;
FreeAndNil(tcp);
end;
Up codes, SockReceiveString with comment has a problem, it never come back sometimes.
mORMot 只UTF8编码 你的文件名称没有转码 编码问题
我直接使用的TSynLog.Family配置log,是不得创建TSynLog实例,然后使用它的FileName属性特意指定文件名?
@ab, give me some hints?
When my app file use chinese, the log file name to be messing(incorrect code page?)
e.g. ä¸æé®é¢ 20141015 152947.log
I just right your .dpr, and here is what is written when you execute the program:
..... header ... 20141013 10403644 info do some stuff
So sounds right to me, right?
But you may be reading the file in debug mode.
In this case, the log content may still be in memory, not already flushed to the disk.
By default, and for a huge performance boost, data is written in a memory buffer, then written to the disk using a background thread.
If you add a "readln" after the "Add.Log" you would see all data appear in the file after a small delay.See TSynLogFamily.BufferSize and TSynLog.Flush method or set TSynLogFamily.AutoFlushTimeOut and the corresponding documentation.
Ok, I add AutoFlushTimeOut := 1; then the log string appear.
Thanks.
I just know that TSynLog can't work reason in my testing project.
My testing project is a console project, and I add 'Readln' procedure at the end, yes, when I add it, my logs lose, when I remove it, my logs are correct!
@ab, is this a bug? Could you check it?
FYI, it works for me when I tried it (I have not committed the latest patch so I still manually added the trailing slash).
with TMyLog.Family do begin Level := [sllInfo, sllError, sllServer]; DestinationPath := ExtractFilePath(Application.ExeName) + 'logs\'; end; TMyLog.Add.Log(sllInfo, 'Testing');
Question for @win2014: Does the logs folder exist?
Of course, I saw it. My mean is log info is not correct.
I have try, like the same.
I added '/' to the 'logs', then log file go into it, but still no my log info, and I open log file, the last line is
TMyLog 1.18.311 2014-10-08T01:05:15
For save time, Just show my codes:
type
TMyLog = class(TSynLog)
end;
begin
with TMyLog.Family do begin
Level := LOG_VERBOSE;
DestinationPath := ExtractFilePath(ParamStr(0)) + 'logs';
end;
TMyLog.Add.Log(sllInfo, 'do some stuff');
end.
I have read the sample one by one, and see that per-class knowledge, but the codes above can't work: the log file created in dir of exe, not the logs dir, the string "do some stuff" not in log file, what happends? My SynCommons is the latest version, I can ensure that.
I just found version info in SynCommons.pas, I'm sure I'm using 1.18
SYNOPSE_FRAMEWORK_VERSION = '1.18'{$ifdef LVCL}+' LVCL'{$endif};
I need to log some HTML page, like this:
TSynLog.Add.Log(sllInfo, aLabel + ' ' + html);
The HTML page length several ten thousand, but I see the </html> often lost, the HTML be truncated! I sure the page is complete.
Somebody help?
Hi @mpv,
Where is the debugger?
Agree with ab. Now SynSM hides so deep.
I call procedure TSMObject.DefineProperty(const name: SynUnicode; const value: variant) like this:
smObj.DefineProperty('propName', 'propValue');
Then it raise 'Unhandled variant type 21' - ESMException.
I read the source clearly and found the kernal rutine
procedure TSMObject.DefineProperty(const name: SynUnicode;
const value: variant; attrs: TJSPropertyAttrs);
begin
DefineProperty(name,VariantToJsVal(cx,value),attrs);
end;
See that? VariantToJsVal cast the value into correct jsval, but it return a jsval type, and no proper DefineProperty() accept this param..so it call itself again..
Try to patch this, I wrote codes instead:
DefineProperty(name,TSMValue(VariantToJsVal(cx,value)),attrs);
Exception has no raise again.
I love the beautiful SynSM, thanks mpv's times.
Regard.
You try to do something with javaScript runtime not from thread this runtime created. If this happens in delphi debugger in multithread application this is "normal" situation, because debugger thread is not a thread where runtime initially created. In our implementation we create one runtime and one context per thread. See Mozilla sources:
JSRuntime::abortIfWrongThread() const { if (ownerThread_ != PR_GetCurrentThread()) MOZ_CRASH(); if (!js::TlsPerThreadData.get()->associatedWith(this)) MOZ_CRASH(); }
Thanks mpv very much. I have read these statement above from sm source and I have trace into cpu viewer for asm, but my asm knowledge as my english, haha...
Thanks excellent sm wrapper again!
@mpv What things to do in JS_AbortIfWrongThread in sm, in delphi debug evironment, I found it raise zero point write av exception.
Hope reply.
I haven't use the log system.
I just use SynSM in a small testing app. The app creates some threads, and those threads run some javascript. Sometimes, this exception raise, sometime no. What means? What happens?
Thanks.
@edwinsn - we prepare all patches and build instruction for SpiderMonkey - I send sources to AB.
@tueddy & win2014 - Yes, we add ability to share Delphi classes with SpiderMonkey. For my main product (commercial) we already done this year ago and now we migrate this part of sources to the Syn*. The main problem is support of both "old" RTTI and new RTTI. I think we solve it in a month.
Our implementation is much speed-efficient compared to http://delphi-javascript.googlecode.com/svn/trunk
Seems good news! Exciting!
I write some "processor-oriented" code fix my question, even they looks ugly, but works.
I had fixed this, see below:
function JS_GetRuntimePrivate(rt: PJSRuntime): pointer; cdecl; external SpiderMonkeyLib name '?JS_GetRuntimePrivate@@YAPAXPAUJSRuntime@@@Z';
procedure JS_SetRuntimePrivate(rt: PJSRuntime; data: pointer); cdecl; external SpiderMonkeyLib name '?JS_SetRuntimePrivate@@YAXPAUJSRuntime@@PAX@Z';
When I use JS_SetRuntimePrivate or JS_GetRuntimePrivate in SynSM, the app directly crash! And then show "Can not locate the program import point JS_SetRuntimePrivate..".
e.g. I defines a type TMyClass = class; in delphi code, then I want use this type in js:
var mycl = new TMyClass();
In delphi-javascript wrap, it could be very easy.
Is there any demo about that?
I had look for this, but found nothing.
There are no problems in XE6, sample TestMustacheUnit runs very well!
I also have a problem when starting TestMustache in Delphi XE3 .
constructor TSMEngine.Create(aManager: TSMEngineManager); ... fCx.Options := [jsoVarObjFix,jsoBaseLine,jsoTypeInference,jsoIon,jsoAsmJs];
Error in line JS_SetOptions(@self,uint32(Value))
procedure JSContext.SetOptions(const Value: TJSOptions); begin JS_SetOptions(@self,uint32(Value)) end;
Value: (from debuger)
[jsoUnused5,jsoUnused11,jsoNoScriptRVal,jsoUnrootedGlobal,jsoBaseLine,jsoPcCount,(out of bound) 22,(out of bound) 25]
Yes, like to me.
All right, I will try more.
I suppose you are not using the latest .dll files.
source code wrote:{
-------------------------------------------------------------------------
Download the SpiderMonkey library at http://synopse.info/files/synsm.7z
and put mozjs-24.dll and libnspr4.dll files with your TestMustache.exe
-------------------------------------------------------------------------
}
Yes, I just download dll from this url, and the source are from github, https://github.com/synopse/mORMot(download zip button).
program SynSMPractise;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
SynSM;
var
engMan: TSMEngineManager;
jsEng: TSMEngine;
begin
try
engMan := TSMEngineManager.Create();
jsEng := engMan.ThreadSafeEngine;
jsEng.Evaluate('var a = 0;');
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
Readln;
engMan.Free();
end.
These are my practice codes,when I run it without ide,is display
"Assertion failure: lock != NULL, at c:/nspr/pr/src/threads/combined/prulock.c:198
EExternalException: External exception 80000003",if I run it in ide debug mode,it crashed in this line: "fCx.Options := [jsoVarObjFix,jsoBaseLine,jsoTypeInference,jsoIon,jsoAsmJs];".
I also get the error External Exception 80000003 when I open the executable file name "TestMustache.exe",my ide is xe3 up2,system is win7,but in xp sp3,it also display.
Pages: 1