Export to GitHub

as3-arduino-connector - issue #33

ReadBytesAsArray() is not thread-safe


Posted on Apr 10, 2015 by Happy Bird

What steps will reproduce the problem? 1. Run bidirectional communication, not ask-wait-read responce .

What is the expected output? What do you see instead? Input data should not be corrupted.

What version of the product are you using? On what operating system? 1.5.0

Please provide any additional information below.

FREObject getBytesAsArray(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) { FREObject result;

FRENewObject((const uint8_t*) "Array", 0, NULL, &result, NULL); FRESetArrayLength(result,bufferSize-1);

FREObject myChar; int i;

pthread_mutex_lock( &safety); for(i=0; i < bufferSize; i++) { FRENewObjectFromUTF8(1,(unsigned char *) buffer+i, &myChar); FRESetArrayElementAt(result, i, myChar); }

bufferSize=0; sentEvent = 0; pthread_mutex_unlock( &safety);

return result; }

pthread_mutex_lock( &safety);

should be placed before

FRESetArrayLength(result,bufferSize-1);

Comment #1

Posted on Apr 14, 2015 by Happy Bear

This project has been moved to GitHub by Google Code. https://github.com/quetwo/as3-arduino-connector Would you mind submitting a pull request there to correct these issues? I would love to include them in a new release.

Status: New

Labels:
Type-Defect Priority-Medium