let "i+=1";
process=`ps | grep workload | grep -v grep | awk '{print $1}'`
kill -9 $process
-ps | grep trans | grep -v grep | awk '{print $1}' | xargs kill #Kill the server
+process=`ps | grep trans | grep -v grep | awk '{print $1}'`
+cat ../../gdbquery | gdb ../../trans.bin $process &> output
+kill -1 $process
+sleep 1
+kill $process
sleep 1;
cd ..
done
public boolean isEmpty() {
return map.isEmpty();
}
-
+ public boolean contains(Object o) {
+ return map.containsKey(o);
+ }
public int size() {
return map.size();
}
--- /dev/null
+public class InetAddress {
+ String hostname;
+ byte[] address;
+
+ public InetAddress(byte[] addr, String hostname) {
+ this.hostname=hostname;
+ this.address=addr;
+ }
+
+ public static InetAddress getByAddress(String host, byte[] addr) {
+ return new InetAddress(addr, host);
+ }
+
+ public static InetAddress getByName(String hostname) {
+ InetAddress[] addresses=getAllByName(hostname);
+ return addresses[0];
+ }
+
+ public byte[] getAddress() {
+ return address;
+ }
+
+ public static InetAddress[] getAllByName(String hostname) {
+ InetAddress[] addresses;
+
+ byte[][] iplist = InetAddress.getHostByName(hostname.getBytes());
+
+ addresses = new InetAddress[iplist.length];
+
+ for (int i = 0; i < iplist.length; i++) {
+ addresses[i] = new InetAddress(iplist[i], hostname);
+ }
+ return addresses;
+ }
+
+ public static native byte[][] getHostByName(byte[] hostname);
+}
/* File Descriptor */
int fd;
- Socket() {
+ public Socket() {
}
+
+ public Socket(String host, int port) {
+ InetAddress address=InetAddress.getByName(host);
+ fd=nativeBind(address.getAddress(), port);
+ nativeConnect(fd, address.getAddress(), port);
+ }
+
+ public Socket(InetAddress address, int port) {
+ fd=nativeBind(address.getAddress(), port);
+ nativeConnect(fd, address.getAddress(), port);
+ }
+
+ public static native int nativeBind(byte[] address, int port);
+
+ public static native int nativeConnect(int fd, byte[] address, int port);
int setFD(int filed) {
fd=filed;
public class Socket {
- /* Data pending flag */
/* File Descriptor */
int fd;
- Socket() {
+ public Socket() {
}
+
+ public Socket(String host, int port) {
+ InetAddress address=InetAddress.getByName(host);
+ fd=nativeBind(address.getAddress(), port);
+ nativeConnect(fd, address.getAddress(), port);
+ }
+
+ public Socket(InetAddress address, int port) {
+ fd=nativeBind(address.getAddress(), port);
+ nativeConnect(fd, address.getAddress(), port);
+ }
+
+ public static native int nativeBind(byte[] address, int port);
+
+ public static native int nativeConnect(int fd, byte[] address, int port);
int setFD(int filed) {
fd=filed;
outstructs.println("#define STRINGTYPE "+typeutil.getClass(TypeUtil.StringClass).getId());
outstructs.println("#define CHARARRAYTYPE "+
(state.getArrayNumber((new TypeDescriptor(TypeDescriptor.CHAR)).makeArray(state))+state.numClasses()));
+
+ outstructs.println("#define BYTEARRAYTYPE "+
+ (state.getArrayNumber((new TypeDescriptor(TypeDescriptor.BYTE)).makeArray(state))+state.numClasses()));
+
+ outstructs.println("#define BYTEARRAYARRAYTYPE "+
+ (state.getArrayNumber((new TypeDescriptor(TypeDescriptor.BYTE)).makeArray(state).makeArray(state))+state.numClasses()));
+
outstructs.println("#define NUMCLASSES "+state.numClasses());
if (state.TASK)
outstructs.println("#define STARTUPTYPE "+typeutil.getClass(TypeUtil.StartupClass).getId());
readSourceFile(state, ClassLibraryPrefix+"FileInputStream.java");
readSourceFile(state, ClassLibraryPrefix+"FileOutputStream.java");
readSourceFile(state, ClassLibraryPrefix+"File.java");
+ readSourceFile(state, ClassLibraryPrefix+"InetAddress.java");
if (state.TASK) {
readSourceFile(state, ClassLibraryPrefix+"Object.java");
readSourceFile(state, ClassLibraryPrefix+"StartupObject.java");
struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
struct ArrayObject * v=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]);
v->type=type;
+ if (length<0) {
+ printf("ERROR: negative array\n");
+ return NULL;
+ }
v->___length___=length;
#ifdef THREADS
v->tid=0;
#else
struct ___String___ * NewString(const char *str,int length) {
#endif
+ int i;
#ifdef PRECISE_GC
struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
- struct ___String___ * strobj=allocate_new((struct garbagelist *) ptr, STRINGTYPE);
+ int ptrarray[]={1, (int) ptr, (int) chararray};
+ struct ___String___ * strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
+ chararray=(struct ArrayObject *) ptrarray[2];
#else
struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
struct ___String___ * strobj=allocate_new(STRINGTYPE);
#endif
- int i;
strobj->___value___=chararray;
strobj->___count___=length;
strobj->___offset___=0;
#include <arpa/inet.h>
#include <strings.h>
#include <errno.h>
+#include <netdb.h>
#include "SimpleHash.h"
#include "GenericHashtable.h"
extern struct RuntimeHash *fdtoobject;
+int CALL23(___Socket______nativeConnect____I__AR_B_I, int ___fd___, int ___port___, int ___fd___, struct ArrayObject * ___address___ ,int ___port___) {
+ struct sockaddr_in sin;
+ int rc;
+
+ bzero(&sin, sizeof(sin));
+ sin.sin_family= AF_INET;
+ sin.sin_port=htons(___port___);
+ sin.sin_addr.s_addr=htonl(*(((char *)&VAR(___address___)->___length___)+sizeof(int)));
+ do {
+ rc = connect(___fd___, (struct sockaddr *) &sin, sizeof(sin));
+ } while (rc<0 && errno==EINTR); /* repeat if interrupted */
+
+ if (rc<0) goto error;
+ return 0;
+
+ error:
+ close(___fd___);
+ return -1;
+}
+
+
+int CALL12(___Socket______nativeBind_____AR_B_I, int ___port___, struct ArrayObject * ___address___, int ___port___) {
+ int fd;
+ int rc;
+ socklen_t sa_size;
+ struct sockaddr_in sin;
+ bzero(&sin, sizeof(sin));
+ sin.sin_family= AF_INET;
+ sin.sin_port=htons(___port___);
+ sin.sin_addr.s_addr=htonl(*(((char *) &VAR(___address___)->___length___)+sizeof(int)));
+
+ fd=socket(AF_INET, SOCK_STREAM, 0);
+ if (fd<0) {
+#ifdef DEBUG
+ perror(NULL);
+ printf("createSocket error in nativeBind\n");
+#endif
+#ifdef TASK
+ longjmp(error_handler,12);
+#else
+#ifdef THREADS
+ threadexit();
+#else
+ exit(-1);
+#endif
+#endif
+ }
+
+#ifdef TASK
+ //Make non-blocking
+ fcntl(fd, F_SETFD, 1);
+ fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)|O_NONBLOCK);
+#endif
+
+ rc = bind(fd, (struct sockaddr *) &sin, sizeof(sin));
+ if (rc<0) goto error;
+
+ sa_size = sizeof(sin);
+ rc = getsockname(fd, (struct sockaddr *) &sin, &sa_size);
+ if (rc<0) goto error;
+
+ return fd;
+
+ error:
+ close(fd);
+#ifdef DEBUG
+ perror(NULL);
+ printf("createSocket error #2 in nativeBind\n");
+#endif
+#ifdef TASK
+ longjmp(error_handler,13);
+#else
+#ifdef THREADS
+ threadexit();
+#else
+ exit(-1);
+#endif
+#endif
+}
+
+struct ArrayObject * CALL01(___InetAddress______getHostByName_____AR_B, struct ___ArrayObject___ * ___hostname___) {
+ int length=VAR(___hostname___)->___length___;
+ int i,j,n;
+ char * str=malloc(length+1);
+ struct hostent *h;
+ struct ArrayObject * arraybytearray;
+
+ for(i=0;i<length;i++) {
+ str[i]=(((char *)&VAR(___hostname___)->___length___)+sizeof(int))[i];
+ }
+ str[length]=0;
+ h=gethostbyname(str);
+ free(str);
+
+ for (n=0; h->h_addr_list[n]; n++) /* do nothing */ ;
+
+#ifdef PRECISE_GC
+ arraybytearray=allocate_newarray(___params___,BYTEARRAYARRAYTYPE,n);
+#else
+ arraybytearray=allocate_newarray(BYTEARRAYARRAYTYPE,n);
+#endif
+ for(i=0;i<n;i++) {
+ struct ArrayObject *bytearray;
+#ifdef PRECISE_GC
+ {
+ int ptrarray[]={1, (int) ___params___, (int)arraybytearray};
+ bytearray=allocate_newarray(&ptrarray,BYTEARRAYTYPE,h->h_length);
+ arraybytearray=(struct ArrayObject *) ptrarray[2];
+ }
+#else
+ bytearray=allocate_newarray(BYTEARRAYTYPE,h->h_length);
+#endif
+ ((void **)&((&arraybytearray->___length___)[1]))[i]=bytearray;
+ for(j=0;j<h->h_length;j++) {
+ ((char *)&((&bytearray->___length___)[1]))[j]=h->h_addr_list[i][j];
+ }
+ }
+
+ return arraybytearray;
+}
+
+
int CALL12(___ServerSocket______createSocket____I, int port, struct ___ServerSocket___ * ___this___, int port) {
int fd;
int n=1;
struct sockaddr_in sin;
- bzero (&sin, sizeof (sin));
+ bzero(&sin, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons (port);
sin.sin_addr.s_addr = htonl (INADDR_ANY);
if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (char *)&n, sizeof (n)) < 0) {
close(fd);
#ifdef DEBUG
- perror(NULL);
+ perror("");
printf("createSocket error #2\n");
#endif
#ifdef TASK
/* bind to port */
if (bind(fd, (struct sockaddr *) &sin, sizeof(sin))<0) {
- close (fd);
+ close(fd);
#ifdef DEBUG
- perror(NULL);
+ perror("");
printf("createSocket error #3\n");
#endif
#ifdef TASK
if (listen(fd, 5)<0) {
close (fd);
#ifdef DEBUG
- perror(NULL);
+ perror("");
printf("createSocket error #4\n");
#endif
#ifdef TASK
if (byteread<0) {
printf("ERROR IN NATIVEREAD\n");
+ return 0;
}
#ifdef TASK
flagorand(VAR(___this___),0,0xFFFFFFFE);