Flux RSS des billets

DotMG's joblog

Work hard at whatever you do! (Ecc. 9. 10a)
Publié le 17 Fév 2015, 1:21 pm dans iseries, linux

About 1 month ago, my ISP replaced my internet box with a newer version, because of instabilities of my old box. I was very pleased to see I was able to put it anywhere at home and get connected, where the older one could only be put in a window at my attic. I could also bring it at church and get connection there, so I can now imagine some internet activities for the little children there. More: the speed was much better.

But there was a drawback. While the speed seemed better, my telnet sessions get disconnected every five minutes of being idle. That issue did not occur with my old box, and I could leave my telnet session open and idle for hours, without any drop. It was a pain to have to reconnect and enter my passwords each time, and mostly when an interactive task stopped because of idle timeout.

These telnet sessions are connections to an AS400 machine, and I used to use the xtn5250 software. xtn5250 is an opensource and "nearly full options telnet 5250 terminal emulator". I was looking at the net to find a possible solution to these session drops, and these searches lead me to fixing it myself.

It's worth noting that in the past, I have contributed an enhancement suggestion for this software, because I had to work with an AS400 where the port 23 was mapped to another port for the outside world, because of ipv4 limitations, and xtn5250 (as the proprietary Client Access on Windows) could only connect to port 23. So, I tried a solution adding setKeepAlive(true) to the socket and it worked. No more session drops.

I am not a Java programmer, but with some research, I was able to fix an issue, and forked the original project. That's the beauty of opensource.

Publié le 18 Oct 2013, 3:52 pm dans iseries

I have been coding with RPG/400 for more thant 12 years. These are a number of opcode I've never used, and I even didn't knew exactly what do they mean, and for which purpose may I need to use them.

One of these is FEOD : Force End Of Data.

The FEOD operation signals the logical end of data for a primary, secondary, or full procedural file. The FEOD function differs, depending on the file type and device. (For an explanation of how FEOD differs per file type and device, see the Database Guide, SC41-9659.)

FEOD differs from the CLOSE operation: the program is not disconnected from the device or file; the file can be used again for subsequent file operations without an explicit OPEN operation being specified to the file.

You can specify conditioning indicators. Factor 2 names the file to which FEOD is specified. You can specify a resulting indicator in positions 56 and 57 to be set on if the operation is not completed successfully.

To process any further sequential operations to the file after the FEOD operation (for example, READ or READP), you must reposition the file.

According to its definition, it's like a CLOSE but does not disconnect the program? In fact, this explanation does not say why it may be needed. To understand its use, we must know the mechanism that takes place when you write or read a record in an RPG program.

Physically, the program has 3 resources for storing data : the hard disk : the non-volatile storage device, the RAM buffer, and a DB layer. When you issue the WRITE operation, the record is not necessarily written to disk, it is written to the RAM buffer. Writing to hard disk happens only when the program ends, or when the RAM buffer is full, or when you ask it to be written, by using the FEOD opcode. When you try to access the record with embedded SQL, the program only look at the DB layer, which may be linked to the hard disk, not the RAM buffer. What this means is that, if you write 5 records to your file, then use embedded SQL to access the newly written records, you may not see them.

So, if you mix a SQL opcode WRITE and embedded SQL SELECT in your program, to ensure a correct synchronisation, you must issue an FEOD opcode after each WRITE. This asks the program to write data to disk without waiting for the buffer to be full. It alters performance but this can help you avoid strange results with your application.

Publié le 8 Oct 2013, 6:42 am dans apache

I recently purchased a wildcard SSL for my domain *.dot.mg. I have many subdomains that I wanted also to serve as https.

Once the SSL installed and fully functional, accessing to any of the subdomains leaded to the main site, because SSL configuration is per IP address, and not per domain name. But the solution is very simple, and in 3 lines. It is done by proxying requests to the main site to the non-https version. So, visitor connectes via https to https://blog.dot.mg/, but this request is directed to my main site https://dot.mg/. It will be the responsibility of https://dot.mg/ to redirect internally this request into http://blog.dot.mg/

It is important to know the difference between normal redirection and proxy redirection. With normal redirection, when a visitor goes to https://blog.dot.mg/, he is asked to go to http://blog.dot.mg instead, so he will load the unsecure version of the site. On the other hand, with proxy redirection, it is the webserver who will load the unsecure version of the site, then change all references to http into https and give the modified html page to the visitor. Thus, the communication between the client and the server is secure

 RewriteCond %{HTTP_HOST} ^blog.dot.mg$
 RewriteCond %{HTTPS} =on
 RewriteRule ^(.*)$ http://blog.dot.mg/$1 [P,L]

As simple as that.

The first lines filters the rewriting rule only for the subdomain blog.dot.mg. The second applies only the rule for HTTPS. The third line does the proxy redirection. Note the flag P instead of R. It is the only trick that makes it possible to view the site through https.

Publié le 29 Mar 2013, 10:43 am dans linux

To be able to connect to a remote machine without the need to enter password, you use authentication by keyring, by copying your public key into the remote machine's list of authorized keys. ssh-copy-id is an interesting little utility that does just that.

ssh-copy-id root@my.new.server

This will ask once for the root password of my.new.server and install the public key of the user running this command into the remote machine's authorized keys. It's also possible to install another identity (for example, installing normal user public_key while logged-in as root on your local computer), by using the -i identity_file parameter.

Next time you login into the remote server, you won't be asked for a password

If you happen to encounter this error message: ssh-copy-id: ERROR: No identities found, it means that the current user doesn't have yet a public key. The solution is simple and one word: ssh-keygen

Publié le 18 Mar 2013, 3:41 pm dans iseries
I've run a should-be-simple SQL statement joining two large tables.
select * from bad_customer a, customers b
where a.CUSTID < 1000 and a.REGION=b.REGION and a.DEPTNO = b.DEPTNO

Table a has index on CUSTID field, table b has an index on fields REGION, DEPTNO and ZIP

Logically, no matter how big the table customers is, this statement should be performed very quickly, as fields REGION and DEPTNO are the first and second index of an index of the table customers. However, it took an eternity.

I've run the statement in STRSQL to see why this takes so long, I saw that an access path was being created for the table customers. Then, it took me 1 day to figure out the cause. On the table bad_customer, REGION was declared decimal(5, 0) although its value is always less than 10000. On the table customers however, the definition of the field REGION was decimal(4, 0). Due to this difference of field definition, the logical index could not be used to access table customers.

Replacing a.REGION with CAST(a.REGION as decimal(4, 0)) solved the issue.

select * from bad_customer a, customers b
where a.CUSTID < 1000 and 
cast(a.REGION as decimal(4, 0))=b.REGION and a.DEPTNO = b.DEPTNO
Pages: 1 2 3 4 5